Created
September 18, 2025 15:17
-
-
Save skozz/96119e0487f7753ba311200e144d80f8 to your computer and use it in GitHub Desktop.
scripts/test-log.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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."); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
