Problem
.github/scripts/workflows/metrics-collection-orchestrator.cjs calls main() at module top-level (line 258), and main() calls process.exit(1) on failure (line 207/260). Its own test file (.github/scripts/workflows/__tests__/metrics-collection-orchestrator.test.js) require()s this module directly, so importing it for testing runs the whole orchestrator for real and can call process.exit(1) mid-test-run.
In this environment (no network access to whatever the collector calls), every collection attempt fails (✅ Successful: 0/1, ❌ Failed: 1/1), triggering process.exit(1) — which kills the entire Jest process outright, not just this one test file. Any npm run test run that reaches this file never produces a final summary.
Impact
Blocks getting a reliable full-suite pass/fail count locally. Discovered while verifying PR #3341 (issue #3340) — excluding this one file was required to get a clean Test Suites: 29 failed, 177 passed, 206 total summary.
Suggested fix
Guard the module so main() only runs when the file is executed directly, not when required:
if (require.main === module) {
main().catch((error) => {
console.error("Fatal error:", error);
process.exit(1);
});
}
This is the standard Node pattern for CLI scripts that are also required as test fixtures, and matches how other agent scripts in this repo are already structured.
Also seen (separate, in the same investigation)
scripts/agents/issues.agent.cjs:13 — const __filename = __filename || process.argv[1]; throws SyntaxError: Identifier '__filename' has already been declared (Jest treats the file as CommonJS, where __filename is already a module-scope binding). One of the 29 suites still failing after #3341.
Problem
.github/scripts/workflows/metrics-collection-orchestrator.cjscallsmain()at module top-level (line 258), andmain()callsprocess.exit(1)on failure (line 207/260). Its own test file (.github/scripts/workflows/__tests__/metrics-collection-orchestrator.test.js)require()s this module directly, so importing it for testing runs the whole orchestrator for real and can callprocess.exit(1)mid-test-run.In this environment (no network access to whatever the collector calls), every collection attempt fails (
✅ Successful: 0/1,❌ Failed: 1/1), triggeringprocess.exit(1)— which kills the entire Jest process outright, not just this one test file. Anynpm run testrun that reaches this file never produces a final summary.Impact
Blocks getting a reliable full-suite pass/fail count locally. Discovered while verifying PR #3341 (issue #3340) — excluding this one file was required to get a clean
Test Suites: 29 failed, 177 passed, 206 totalsummary.Suggested fix
Guard the module so
main()only runs when the file is executed directly, not when required:This is the standard Node pattern for CLI scripts that are also required as test fixtures, and matches how other agent scripts in this repo are already structured.
Also seen (separate, in the same investigation)
scripts/agents/issues.agent.cjs:13—const __filename = __filename || process.argv[1];throwsSyntaxError: Identifier '__filename' has already been declared(Jest treats the file as CommonJS, where__filenameis already a module-scope binding). One of the 29 suites still failing after #3341.