45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
#!/usr/bin/env node
|
|
// e2e/run-tests.js
|
|
// Lee e2e/tests.json y ejecuta validate-flow-remote-chrome.js para cada caso en serie.
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const { spawn } = require('child_process');
|
|
|
|
const testsPath = path.resolve(__dirname, 'tests.json');
|
|
if (!fs.existsSync(testsPath)) {
|
|
console.error('tests.json not found at', testsPath);
|
|
process.exit(2);
|
|
}
|
|
|
|
const tests = JSON.parse(fs.readFileSync(testsPath, 'utf8'));
|
|
|
|
async function runTest(t) {
|
|
return new Promise((resolve) => {
|
|
console.log('\n=== Running test:', t.name, '===');
|
|
const env = Object.assign({}, process.env, t);
|
|
// Use the helper script if CHROME_HOST provided; else require CHROME_WS
|
|
const script = path.resolve(__dirname, 'run-remote-chrome.sh');
|
|
const proc = spawn('bash', [script], { env, stdio: 'inherit' });
|
|
proc.on('close', (code) => {
|
|
console.log(`Test ${t.name} finished with code ${code}`);
|
|
resolve(code);
|
|
});
|
|
proc.on('error', (err) => {
|
|
console.error('Failed to spawn process for', t.name, err);
|
|
resolve(3);
|
|
});
|
|
});
|
|
}
|
|
|
|
(async () => {
|
|
for (const t of tests) {
|
|
const code = await runTest(t);
|
|
if (code !== 0) {
|
|
console.warn('Test failed, stopping further tests. Last code:', code);
|
|
process.exit(code || 1);
|
|
}
|
|
}
|
|
console.log('\nAll tests passed (or completed).');
|
|
})();
|
|
|