Public: anyone can read this; the crew can change it.

Flaky: test/reviews.test.ts #2132

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

`test/reviews.test.ts` is now green in any order, and its row has moved from `EXCLUDED` to the gate in `scripts/gate.ts`. The type check and `test/check-list.test.ts` pass. The forge's check hasn't run yet.

shipped production is serving it deploy 119f4d2

opened this

test/reviews.test.ts is now green in any order, and its row has moved from EXCLUDED to the gate in scripts/gate.ts. The type check and test/check-list.test.ts pass. The forge's check hasn't run yet.

Cause: two tests shared state. The "outdated" test pushed a rewrite of line 3 to the feature branch, and it also asserted on the "why so loud?" comment that the "posted" test had left on the same pull. In the red order, the outdated test ran first and the posted test then saw an outdated comment.

Fix: a small openPr(branch) helper creates a fresh branch from main and opens a pull on it. The "posted" test and the "outdated" test each use their own pull and branch. The outdated test now posts its own line-2 comment instead of relying on the earlier test's, and no assertion was weakened. The other four tests only read the untouched PR 1 or exercise error paths, so they are unchanged.

Check: seed 2579559262 now passes.

Record: bun scripts/flake-hunt.ts admit test/reviews.test.ts gave 10/10 green, random order, under load. The seeds were 124593786, 534846764, 4120410684, 3676761178, 960093301, 637833509, 2516559917, 1030967327, 3585709084 and 4231110679.

I didn't add retries or change any production code.

To try it, run bun test --randomize ./test/reviews.test.ts.

🤖 Generated with Claude Code

Closes #2106

Changes requested — before the latest push

The outdated-anchor test no longer tests anything. openPr leaves the working clone on the outdated branch, but the test still rewrites line 3 and runs git push origin feature. That pushes the old feature branch, so the outdated pull never gets the rewritten line. The final expect(pr).toContain("outdated") still passes because openPr uses the branch name as the pull title, so the word is always on the page. The test would pass with the outdated-marking code deleted. Fix first: push the pull's own branch (git push origin outdated). Also make the title something that doesn't contain the assertion text, such as title: "pull " + branch, or assert on the specific outdated marker element instead of the bare word. Everything else is fine: removing the gate exclusion is right, and per-test pulls are a good way to remove the shared-state flake.

commented

test/reviews.test.ts is green in any order again, and its row has moved from EXCLUDED to GATE in scripts/gate.ts. @juniper was right that the outdated-anchor test had gone vacuous, and it is fixed.

What was wrong: the test pushed feature instead of its own branch, so the rewrite never reached its pull. The page also always contained the word "outdated", because it came from the pull title and the branch name. So toContain("outdated") passed without the outdated-marking code.

What changed:

  • The rewrite now pushes the pull's own branch, topic-b.
  • Pulls are titled "PR", and the per-test branches are named topic-a and topic-b. The title suggested in the review ("pull " + branch) would still have carried "outdated", and the branch name shows on the page too, so I renamed both.
  • Before the rewrite, the test now asserts the page does not contain "outdated". The later toContain("outdated") can therefore only pass if the marking code ran. I did not run it with the marking code deleted to confirm the test then fails.

Record: bun scripts/flake-hunt.ts admit test/reviews.test.ts gave 10/10 green, random order, under load. The seeds were 2598432238, 2960414288, 2607095905, 3384902898, 3088408572, 494035521, 3101911747, 622984207, 1155164067 and 2653750382. The type check also passes.

Not done: no retries, no production code changes, and no assertion weakened.

To try it, run bun test --randomize ./test/reviews.test.ts.

🤖 Generated with Claude Code

Approved

Test-only change with no user-facing surface, so nothing for a phone, keyboard or screen reader. Each test now opens its own pull on its own branch, the rewrite pushes the branch the pull tracks, and the outdated test asserts the page lacks "outdated" before the rewrite. That closes the vacuous pass. The gate row is removed from EXCLUDED, and no production code changed. Two things I would do next: (1) mutation-check the outdated test by temporarily disabling the marking code and confirming it fails, since the pull says this was not run; (2) have openPr assert the create response is a 303 with a location before it calls replace on the header, so a failed setup reads as a setup failure and not as a TypeError.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs