This site uses one functional cookie to keep feature rollouts consistent for you. Nothing is set until you choose. See the privacy notice.
Dev notes
A CI run printed 137 dots and a green check, and I asked what it had actually run. Answering that turned into running every test file by itself, in a random order, and judging each test on one question: if the behaviour it is named for broke, would this fail? About one test in seven would not. The suite had 4,561 tests when I started and more than 7,400 when I stopped, and the interesting part is not the number that went up. It is how many different ways a green run can say nothing.
Vitest already isolates each file, so I expected nothing from running them alone. I ran all 504 with their tests shuffled, under two seeds. Three failed, every one of them green in the normal run:
ResearchContent refreshes the evidence scan on demand AssertionError: expected 6 to be 1 MindReaderContent mounts the Svelte game into the page and tears it down on leave AssertionError: expected "vi.fn()" to be called 1 times, but got 4 times DesignSystemShowcaseContent opens and closes the live dialog from the keyboard Error: Unable to find role="button" and name `/open the dialog/i`
My first diagnosis of the first one was wrong. I said an earlier test’s request was still in flight and landing on the next test’s handler, which is a real thing that happens and looked right. The cause was a hook with a module-level cache that localStorage.clear() never reset, so custom topics leaked from one test into the next. The second left mocks uncleared. The third let the page URL, which the explorer writes with replaceState, carry a filter into whichever test ran after it. None of the three was a bug in the page. All three were tests borrowing state from their neighbours, which is exactly the kind of dependence a fixed order never shows.
Reading a test tells you what it intends. Breaking the code under it tells you what it does. For each file I changed the source in a small way (negate a condition, move a boundary, drop an error branch), reran just that file, and recorded whether anything went red, then put the source back. Roughly 5,700 of those across the suite, by the reviewers’ own tallies. On the write-up page tests alone, I also ran 63 mutations against the original versions of the tests and 53 of them survived.
The optimistic-update tests for calendar events and countdowns said they checked that a failed write puts the old data back. Twelve of them passed with every onError rollback deleted. After a failure the query refetches, the refetch returns the real data, and the screen is correct again, so the test could not tell a working rollback from a missing one. They only failed once they looked at the screen before the refetch landed.
One looped over the features that have no write-up and checked each had an empty reel. Every feature has a write-up now, so the loop ran zero times and the test passed on no evidence. Another guarded that a minor release has a public update entry, and returned early for any patch version, so on 9.2.28 it asserted nothing at all. Both read as rules in the file and were silent in practice.
This is the part I did not expect. The weak tests were the obvious kind of finding. The rest were around the tests, and I hit most of them myself while checking my own work:
Error: No tests found and the step was allowed to fail.--max-warnings 0, planted a warning to prove it, and my shell reported exit 0 again.The one I keep coming back to is my own. I wrote a test for the new reporter config, ran it, and read this:
Tests 4 passed (4) Errors 1 error exit=1
Four green tests and a failing run, from an unhandled NetworkError the config import triggered in a browser-like environment. I had read only the first line the first time. Then the opposite happened: the same pnpm lint run through my output-compressing shell wrapper said ESLint: 0 errors, 1 warnings and exited 0, and run unfiltered it said this:
1:7 warning 'unusedOnPurpose' is assigned a value but never used. ✖ 1 problem (0 errors, 1 warning) ESLint found too many warnings (maximum: 0). ELIFECYCLE Command failed with exit code 1.
An exit code and a summary line are each a tool’s opinion of the run. The log is the run.
Finding these once is not worth much if the next one gets in the same way, so each of them became something that fails the build:
expect.requireAssertions for every test. It found three tests in 7,447 that asserted nothing: expected any number of assertion, but got none.VITEST_SEED=<n>..only test, and on an expected failure that does not say which bug it is waiting on.Each guard was proved the same way the tests were: I planted the failure (a skipped test, an untested route, a lint warning) and watched it go red, then took it out.
it.fails with a comment naming the bug. It keeps a known bug visible and red in the right way, and it turns the build red when someone fixes it without removing the marker.Each is held as an expected failure with its reason, so the suite stays green and the bug stays written down. I flipped all twenty back to ordinary tests to check they fail for the reason they name, not for a typo. A few of the failures, as they read:
expected 503 to be 400 a store id that climbs out of the path
expected 'stalefresh' to be 'fresh' a second start() leaves the first stream running
expected 502 to be 204 a backend 204 turned into a 502
expected 404 to be 400 a malformed id on the restock routes
expected [ 10, 29, 23, 59 ] to deeply equal [ 10, 30, 23, 59 ]
a date range off by one day west of UTC
expected '//evil.example/x' not to match /^\/\//
a protocol-relative return pathA generated test suite looks thorough. The count is high, every test has a plausible name, the run is green, and the summary that comes with it is confident. Nearly all of what I found here fits that description, and none of it would have shown up by reading the output. It is the same shape I wrote about in Green Checks, where each check was measuring something other than what it claimed, and in the section on AI-written code in Errors people can read. A model is good at producing the form of a verification. Whether the verification can fail is a separate question that someone has to ask.
Update — November 21, 2026
All twenty expected failures are ordinary tests now and the suite exits 0. Fifteen root causes, one commit each. Most were a line or two. Three of them were not what the note on the test said.
The note blamed the empty string after a final \n being read as a blank line. True, but fixing only that would have left the other half: eventType and dataLines were declared inside feed(), so a chunk that ended between two lines of one event started the next call with a fresh event. The fix moved them up beside the buffer and kept only the unfinished last line in it.
My first fix rejected a //evil.example/x pathname outright. It looked right and failed the test, because the assertion is expect(result).not.toMatch(...) and that matcher throws on a null:
Tests 1 failed | 45 passed (46) FAIL never hands back a protocol-relative path
So I collapsed the leading slashes to one instead, which keeps the result on this origin. Then I noticed I had done that after the /auth/ check, so //auth/login would have come back as /auth/login and looped into the auth routes. The collapse now runs before both checks.
Cancelling the old reader in start() is the fix, but the test then calls sendEvent on the first stream after it was cancelled, and a real source cannot do that:
throws Invalid state: Controller is already closed
I made the helper skip the enqueue once cancelled. The assertion did not change, and it still fails without the fix because the stale token only arrives if the first reader is left open. The read loop also leaves state alone once it is no longer the current reader, otherwise the old loop finishing would have switched isStreaming off in the middle of the new run.
The shared test helpers are unchanged: the operator seed and factories still use Math.random and the real clock, and the reset between tests leaves some state behind. One file failed once under shuffle seed 1234 on a loaded machine and passed nine reruns. I could not reproduce it, so I have not written a fix for it.
Update — November 21, 2026
The update above ends with a list of things I left alone. Leaving them was the wrong call, since each one was a way for a green run to lie. So I went back for them: the shared helpers, and the one file that failed once under shuffle seed 1234.
The failure was reported on a loaded machine and passed nine reruns on a quiet one. Seed 1234 on its own passes. Running the whole suite under it passes too, all 7,207 tests. What changed it was putting load under the file: eight busy processes per core, and the same seed.
× has no axe violations 7663ms → Test timed out in 5000ms. × lists the newest update first, and the oldest first once the order is flipped 6608ms → Test timed out in 5000ms.
It was never about order. Each test in UpdatesContent renders or re-renders every update card, about 76 of them and one more every release, and idle that takes a few hundred milliseconds. Under load it is ten to twenty times that.
I put a longer timeout on the axe test and the sort test, reran under the same load, and it went green. Then I read the other durations in that run: the category chip, the expand toggle and the tag filter were all above four seconds. Fixing the two that happened to cross the line would have moved the flake to whichever test lost the next toss, so the timeout is on the whole describe instead.
The operator factories now take a random function and a clock, and the test setup pins both before the mock server loads, since loading it is what builds the seed. Everything else is the default it was: the demo seed that serves the app when the backend is asleep still uses the real dice and the real time. I pinned the factories first and ran the suite:
FAIL operator aggregation parity > product performance category index and dead SKU AssertionError: expected [ [ 'Kombucha', +0, false ] ] to deeply equal [ [ 'Cola', 200, true ], …(2) ]
The seed was dated June 17 and the code under test windows the last 7 days against the real clock, so every sale fell outside it. A seed fixed at one instant and read against another is empty by the next day, which is the real-clock bug turned inside out. The setup now pins Date to the same instant, and the failures went away without touching the code that does the windowing.
With the clock pinned, a bff fallback test failed on a promotion it created with a start date of July 1, 2026 and expected to be active:
AssertionError: expected { id: 'promo-001', …(6) } to match object { percent: 15, status: 'active' }
- "status": "active",
+ "status": "scheduled",It had been written when July was behind us. It would have gone red the other way for anyone who ran it earlier in the year. The dates are now June 1, in the past of the pinned instant, and they stay there.
The handlers waited a random 100 to 300 milliseconds, and the handler tests worked around it by mocking Math.random to 0. I replaced the delay with a constant tick and asserted that a request never rolls the dice. That failed after the fix:
AssertionError: expected "random" to not be called at all, but actually been called 2 times
MSW rolls Math.random itself to id each request, once per fetch. My first attempt to mock the delay export did nothing either, because the setup had already loaded the module. The test now records only the rolls whose stack starts in the handler file, and I ran it against the old handlers to see it fail before trusting it.
resetOperatorWriteState cleared sessions and promotions and nothing else, but the handlers also mutate the seed in place: dismissing an alert, restocking an item, rearranging a planogram. A test that did any of those left it for the next test in the file. It now restores a copy of the seed taken at load, and there is a test per mutation. The shared /api/me handler was also missing isFlagAdmin, which the real route has always returned.
Update — November 21, 2026
A changelog entry from weeks ago says the test run is clean: zero unmatched requests, zero act() warnings. I compared this PR's CI log with develop's to check I had not made the output worse, and neither was clean. Both had the same noise.
I ran VITEST_SEED=1795280842425 pnpm test, the seed from the CI log, and got a green run with no warnings. I then ran it under heavy CPU load and got the same. The log it wrote was 18 lines long, which I should have read as the clue: when it detects an agent, Vitest swaps to a reporter that hides the output of passing tests. My local runs had never shown a console line. With the default reporter named, the replay matched CI to the count:
$ VITEST_SEED=1795280842425 vitest run --reporter=default act warnings 94 unmatched requests 25
Cleaning 94 warnings by hand would last until the next test. So the setup now records every act() warning and every unmatched request and fails the test that caused it. I wrote that first, so I had the list instead of an estimate:
Test Files 19 failed | 560 passed (579)
Tests 31 failed | 7200 passed (7231)The ZeroProof live-update test jumps fake timers forward 31 seconds, and the win celebration's count-up sets state on every frame of it. Each frame logged its own warning. Advancing the timers inside act() fixed that test, and the same one-line helper fixed the polling hook tests and the calendar banner. The axe scans needed the same treatment, since a page with a timer updates while axe waits, so the shared axe helper runs the scan inside act().
The gallery wall and the slot machine imported axe straight from vitest-axe, so my wrapper did nothing for them. They import the shared one now. The remaining fixes were smaller: four ZeroProof endpoints the tour tests never mocked, a card endpoint the event modal asks for, toast dismissals done with a bare .click(), and three sleeps used to assert that something never appears. One of those was my own collection test from earlier in this PR. It now waits for the error message instead of for fifty milliseconds.
The reduced-motion hydration test warned about LazyMotion on some orderings and not others. LazyMotion starts its import in an effect, and effects flush when the hydrating act() ends. I put vi.dynamicImportSettled() inside that same act, where there was no import yet to wait for, and the failure stayed:
An update to LazyMotion inside a test was not wrapped in act(...).
The wait belongs in a second act, after the first has started the import. Setting IS_REACT_ACT_ENVIRONMENT once in the setup also ended the "not configured to support act" warnings from the two hydration files that call React's act without Testing Library.
While running these under load, a plain render in the design-system gallery timed out at five seconds, the same failure as the updates list. I had patched that one file. The default is fifteen seconds now, and the per-file patch is gone.
Update — November 21, 2026
After the act() work I wrote that about a hundred blocks of error output were "a different class", the app logging on paths a test provokes on purpose, and left them. I was wrong about the word "mostly". I widened the guard to every console.error and console.warn and the first run told me what they were.
120 blocks of stderr, in 33 files 52 operator fallback: "fell back to seed data" 15 Auth0 client with no config 14 chart "width(-1) and height(-1)" 11 two children with the same key 1 Body has already been read 27 a failure the test caused on purpose
Card tests, collection tests and pack tests all warned about two children with the key 5. It was not the fixtures. A card draws two background blobs from a hash, each a number from 1 to 6, and the blob component used that number as its React key. About one card in six gets the same number twice. The same number was also used for the gradient id, so two cards on one page shared a gradient and the second colour never showed. Keys are the position now, and the gradient id comes from useId.
Encountered two children with the same key, `5`. Keys should be unique so that components maintain their identity across updates.
The leagues route test called the route twice with one mocked Response. A body can be read once, so the second call threw and the route quietly answered 502. The test only checked the request headers, so it stayed green. Each call gets its own response now.
[BFF] GET /zeroproof/leagues — fetch threw: TypeError: Body is unusable: Body has already been read
Four card-pack tests did the same thing in a smaller way. They only wanted to know which loader the route called, and they handed back an empty slate, so each one also ran the "empty pool" branch. Two inventory tests answered the store request with { store: null }, which fails the schema, so the component logged a ZodError while the test was about something else.
jsdom measures every element as 0 by 0, so Recharts printed that the chart had no size and drew nothing. My first try was a ResizeObserver that answers with 800 by 400. The warning stayed. Recharts renders once at a default of -1, then reads getBoundingClientRect(), which is 0, and warns on both before the observer matters. What works is replacing the container with one that hands its chart a width and height. The charts now draw, so the accessibility scans look at a real chart instead of an empty box.
Where the app logs on purpose, the test now says what it expects. A 401 test asserts the line [zeroproof join league] auth failed, and the operator fallback file allows exactly one sentence, fell back to seed data, and fails on any other. A missing log is a failure too, and a mute button cannot do that. The Auth0 warning went away by giving the tests the same placeholder config the CI build uses.