From c1426e0e2d92090f2d31373db1a2d5c052046a2f Mon Sep 17 00:00:00 2001 From: suin Date: Mon, 13 Apr 2026 21:45:37 +0900 Subject: [PATCH] test: make default-timeout test deterministic across environments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Counting occurrences of "timed out after 100ms" in combined stderr was flaky: Bun sometimes prints the failure message twice per file (once inline, once in the summary block), depending on platform and output mode. Locally the regex matched 2 times; on Linux CI it matched 4. Spawn each fixture file separately and assert exit code and stderr content per file instead. This verifies the essential invariant — each file independently times out at KEST_DEFAULT_TIMEOUT — without depending on output formatting. Co-Authored-By: Claude Opus 4.6 (1M context) --- ts/default-timeout.test.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ts/default-timeout.test.ts b/ts/default-timeout.test.ts index af5a025..c2bc561 100644 --- a/ts/default-timeout.test.ts +++ b/ts/default-timeout.test.ts @@ -21,11 +21,12 @@ test("should timeout at KEST_DEFAULT_TIMEOUT", async () => { writeFileSync(file1, fixtureContent); writeFileSync(file2, fixtureContent); - const result = Bun.spawnSync({ - cmd: ["bun", "test", file1, file2], - env: { ...process.env, KEST_DEFAULT_TIMEOUT: "100" }, - }); - const stderr = result.stderr.toString(); - const matches = stderr.match(/timed out after 100ms/g); - expect(matches).toHaveLength(2); + for (const file of [file1, file2]) { + const result = Bun.spawnSync({ + cmd: ["bun", "test", file], + env: { ...process.env, KEST_DEFAULT_TIMEOUT: "100" }, + }); + expect(result.exitCode).not.toBe(0); + expect(result.stderr.toString()).toContain("timed out after 100ms"); + } });