mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
Add DM test suites and headless e2e CI
This commit is contained in:
1 parent
b4bdb21424
commit
89e82778d6
5 files changed
+391
-63
No files matched your search
@@ -0,0 +1,57 @@
|
||||
import { spawn } from "node:child_process";
|
||||
import { access } from "node:fs/promises";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import path from "node:path";
|
||||
|
||||
const rootDir = path.dirname(fileURLToPath(new URL("../package.json", import.meta.url)));
|
||||
const setupImport = new URL("../tests/test-helpers/setup-localstorage.mjs", import.meta.url);
|
||||
const requestedFiles = process.argv.slice(2);
|
||||
|
||||
if (!requestedFiles.length) {
|
||||
console.error("No test files provided. Usage: node scripts/run-targeted-tests.mjs <file...>");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const testFiles = requestedFiles.map((file) =>
|
||||
path.isAbsolute(file) ? file : path.join(rootDir, file),
|
||||
);
|
||||
|
||||
for (const testFile of testFiles) {
|
||||
try {
|
||||
await access(testFile);
|
||||
} catch (error) {
|
||||
console.error(`Test file not found: ${testFile}`);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
for (const testFile of testFiles) {
|
||||
const relativePath = path.relative(rootDir, testFile);
|
||||
console.log(`\n→ Running ${relativePath}`);
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
const child = spawn(process.execPath, ["--import", setupImport.href, testFile], {
|
||||
stdio: "inherit",
|
||||
});
|
||||
|
||||
child.on("close", (code, signal) => {
|
||||
if (signal) {
|
||||
reject(new Error(`${relativePath} exited with signal ${signal}`));
|
||||
return;
|
||||
}
|
||||
|
||||
if (code !== 0) {
|
||||
reject(new Error(`${relativePath} failed with exit code ${code}`));
|
||||
return;
|
||||
}
|
||||
|
||||
resolve();
|
||||
});
|
||||
|
||||
child.on("error", (error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
console.log("\n✔ Targeted tests passed");
|
||||
Reference in new issue
Block a user