Skip to content

Instantly share code, notes, and snippets.

@skozz
Created September 18, 2025 15:17
Show Gist options
  • Save skozz/96119e0487f7753ba311200e144d80f8 to your computer and use it in GitHub Desktop.
Save skozz/96119e0487f7753ba311200e144d80f8 to your computer and use it in GitHub Desktop.
scripts/test-log.js
// scripts/test-log.js
const { exec } = require("child_process");
const fs = require("fs");
const path = require("path");
exec("npm test", (err, stdout, stderr) => {
if (err) {
const dir = "test-log";
if (!fs.existsSync(dir)) fs.mkdirSync(dir);
const timestamp = new Date()
.toISOString()
.replace(/T/, " ")
.replace(/:/g, "-")
.replace(/\..+/, "");
const file = path.join(dir, `${timestamp}.txt`);
fs.writeFileSync(file, stdout + stderr);
console.error(`❌ Tests failed. Log written to ${file}`);
process.exit(err.code);
} else {
console.log("✅ All tests passed successfully.");
}
});
@skozz
Copy link
Author

skozz commented Sep 18, 2025

Screenshot 2025-09-18 at 17 23 38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment