From 36463a770a9b1e01dd630b1f8bd48d584963005f Mon Sep 17 00:00:00 2001 From: Devin Foley Date: Fri, 20 Nov 2026 20:59:50 -0800 Subject: [PATCH] test(ci): wait for watchdog fixture readiness The worker can create its started marker before the main reporter receives the test-start event. Under CI load the short fixture watchdog then fires in the file-start phase, failing the expected test-name assertion. Wait for both the worker marker and the main reporter event before enabling this test fixture watchdog. Delay the event beyond the fixture stall limit to reproduce the race without depending on host load. Keep the production reporter and every existing deadline and result assertion unchanged. The controlled delay reproduces the failure before the readiness check. All seven reporter tests pass after it, including both real stuck-process cases. Co-Authored-By: Paperclip --- scripts/ci/stalled-file-reporter.test.mjs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/scripts/ci/stalled-file-reporter.test.mjs b/scripts/ci/stalled-file-reporter.test.mjs index ab9e58b70da..35ff44b12e2 100644 --- a/scripts/ci/stalled-file-reporter.test.mjs +++ b/scripts/ci/stalled-file-reporter.test.mjs @@ -97,7 +97,27 @@ test("passes", () => {}); let fixtureReporter = reporterPath; if (label === "a test that never settles") { fixtureReporter = path.join(directory, "after-test-start.mjs"); - writeFileSync(fixtureReporter, 'import Base from ' + JSON.stringify(pathToFileURL(reporterPath).href) + ';\nimport { existsSync } from "node:fs";\nexport default class extends Base { check() { if (!existsSync(' + JSON.stringify(startedMarker) + ')) return; super.check(); } }\n'); + writeFileSync(fixtureReporter, ` +import Base from ${JSON.stringify(pathToFileURL(reporterPath).href)}; +import { existsSync } from "node:fs"; +export default class extends Base { + ready = false; + onTestCaseReady(testCase) { + if (testCase.module.moduleId !== ${JSON.stringify(path.join(directory, "stuck.test.mjs"))}) { + super.onTestCaseReady(testCase); + return; + } + setTimeout(() => { + super.onTestCaseReady(testCase); + this.ready = true; + }, this.limitMs + 500); + } + check() { + if (!this.ready || !existsSync(${JSON.stringify(startedMarker)})) return; + super.check(); + } +} +`); } const configFile = path.join(directory, "vitest.config.mjs"); writeFileSync(configFile, `export default ${JSON.stringify({ test: { include: ["*.test.mjs"],