Files
TS-CUCUMBER-WDIO-QK/scripts/run-profile.mjs
isopropilick 29899223e4
Some checks failed
CI / validate (push) Has been cancelled
Enhance CI configuration and documentation; add new action palette adapter
2026-09-15 10:32:11 -06:00

43 lines
1.3 KiB
JavaScript

import { spawn } from 'node:child_process';
import { pathToFileURL } from 'node:url';
import { ExecutionDataManager, buildReport } from '@qacg/qk-test-analytics';
export async function executeAndReport(run, report) {
let exitCode = 1;
try {
exitCode = await run();
} catch (error) {
console.error('[QKForce] Runner failed:', error.message);
}
try {
await report();
} catch (error) {
console.error('[QKForce] Report generation failed:', error.message);
return exitCode || 1;
}
return exitCode;
}
function runWdio() {
return new Promise((resolve, reject) => {
if (!process.env.npm_execpath) {
reject(new Error('Start the fixed profile with npm run qkforce:test'));
return;
}
// The command is fixed locally. No package manifest field supplies a shell command.
const child = spawn(process.execPath, [process.env.npm_execpath, 'run', 'test:wdio'], {
stdio: 'inherit', shell: false
});
child.once('error', reject);
child.once('close', code => resolve(code ?? 1));
});
}
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
new ExecutionDataManager().archiveCurrentReport();
process.exitCode = await executeAndReport(runWdio, () => buildReport({
reportsDir: 'qreport-results/media-bucket/reports',
output: 'qreport-results/index.html'
}));
}