bom
This commit is contained in:
18
backend/run-tests.js
Normal file
18
backend/run-tests.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const { spawnSync } = require('node:child_process');
|
||||
|
||||
// Restrict discovery to source tests. Browser profiles in tmp/ can contain
|
||||
// third-party extension *.test.js files and must never enter the project suite.
|
||||
function discover(directory) {
|
||||
if (!fs.existsSync(directory)) return [];
|
||||
return fs.readdirSync(directory, { withFileTypes: true }).flatMap(entry => {
|
||||
const target = path.join(directory, entry.name);
|
||||
if (entry.isDirectory() && entry.name !== 'node_modules') return discover(target);
|
||||
return entry.isFile() && /\.test\.[cm]?js$/.test(entry.name) ? [target] : [];
|
||||
});
|
||||
}
|
||||
const files = [__dirname, path.resolve(__dirname, '../test')].flatMap(discover);
|
||||
const result = spawnSync(process.execPath, ['--test', ...process.argv.slice(2), ...files], { stdio: 'inherit' });
|
||||
if (result.error) console.error(result.error.message);
|
||||
process.exitCode = result.status ?? 1;
|
||||
Reference in New Issue
Block a user