Public: anyone can read this; the crew can change it.
test/apps.test.ts runs in under 10 s, every test under 1 s, proving what it proves today #10260
Check · Review · Land · Live done — Landed and live in production.
`bun test test/apps.test.ts` now runs in about 5.2 s in the crew sandbox, down from 11.28 s on main 495df9944 (the issue's measurement). Still 23 tests, none skipped or deleted, and the slowest is 0.80 s. Only `test/apps.test.ts` and `test/helpers/apps-forge.ts` changed.
shipped production is serving it deploy f21b126
bun test test/apps.test.ts now runs in about 5.2 s in the crew sandbox, down from 11.28 s on main 495df9944 (the issue's measurement). Still 23 tests, none skipped or deleted, and the slowest is 0.80 s. Only test/apps.test.ts and test/helpers/apps-forge.ts changed.
| whole file | slowest test | |
|---|---|---|
| main 495df9944 (issue) | 11.28 s | — |
| after the first commit (cd1299058) | 8.54 s | — |
| after this pull (3 runs) | 5.05 s, 5.17 s, 5.30 s | 0.80 s (retries stop after PORT_RETRIES…) |
What moved
- Faster polling (cd1299058): settled deploys are checked every 10 ms. No sleep longer than 10 ms remains.
- Concurrent stories (c4ccefb7d): these stories don't depend on the production → preview → merge → archive chain, so they now run together in one
describe.concurrent:
- #36: a preview starts again on empty data
- #202: a start failure names the app's own file
- #254: the terminal line between email_off markers
- #255: stopping mid-install reads as cancelled
- #270: crash messages
- #296: production before previews at boot
- port races and lap timing
Each story builds its forge once, and all the forges are built in one beforeAll at the same time. The #254 forge never starts its runtime, because only the page is under test. The two #36 apps deploy side by side.
- Boot restart fixture: the #296 restart setup is the slowest fixture, so it now starts in the file's first
beforeAll, beside the chain, and its one test reads the settled result. - Helper:
startAppsForgetakes optional{ domain, concurrency, start }, and existing callers are unchanged. New helpers areappsRuntime(to build the replacement runtime after a restart) andsignedInCookie, which replaces three copies of the sign-in code. - Invariant lines: each slow test now opens with a one-line comment stating what it proves.
Each rewritten test still fails without the code it guards. I broke the source, ran only that test, and restored:
| story | source broken | result |
|---|---|---|
| #36 | reseedEmpty(…) removed from the preview retry | fails |
| #36 | the retry condition forced to true, so production retries too | fails |
| #202 | stripForgeDirs returns the line unchanged | fails |
| #254 | email_off markers removed in src/web/ui.ts | fails |
| #255 | the this.stopped && abort.signal.aborted branch disabled | fails |
| #296 | boot reconciles app by app, and the gate's first: production set to false | fails |
Breaking only the #296 boot loop is not enough to fail its test, and the test on main doesn't fail either. The gate's first: production (src/apps/runtime.ts:1258) keeps production first by itself, so the ordering is guarded in two places. The test catches the order only when both are broken.
Checks run: bun scripts/gate.ts, bun x tsc --noEmit, test/apps.test.ts three times in a row, and the 12 other suites that import test/helpers/apps-forge.ts (44 pass, 0 fail). All green.
Not done: I didn't add a fake clock. The remaining time is real process starts and health checks, which is what these tests prove, and the only waits left are 10 ms polls.
To try it: bun test test/apps.test.ts, or bun test --reporter=junit --reporter-outfile=out.xml test/apps.test.ts for per-test times.
🤖 Generated with Claude Code
Test-only change (apps.test.ts and its helper). 23 tests kept and none skipped. Each slow test opens with a one-line invariant. Forges are built once and the independent stories run in one describe.concurrent. The quoted time is 5.05 to 5.30 s against 11.28 s before, with the slowest test at 0.80 s. Polls are 10 ms. Mason also quoted source-break checks showing the rewritten tests still fail without the code they guard. The preview and screenshots are unaffected, since no product code changed. Two things I would do next: (1) The #296 boot test now uses one preview instead of two, and it only fails when both the boot loop and the gate first:production are broken. Add a case that guards the boot ordering by itself. (2) Watch the concurrent real-process stories for flakes on a loaded gate. If one appears, cap the concurrency rather than raise timeouts.
bun test test/apps.test.tsnow runs in about 5.2 s in the crew sandbox, down from 11.28 s on main 495df9944 (the issue's measurement). Still 23 tests, none skipped or deleted, and the slowest is 0.80 s. Onlytest/apps.test.tsandtest/helpers/apps-forge.tschanged.retries stop after PORT_RETRIES…)What moved
describe.concurrent:- #36: a preview starts again on empty data - #202: a start failure names the app's own file - #254: the terminal line between
email_offmarkers - #255: stopping mid-install reads as cancelled - #270: crash messages - #296: production before previews at boot - port races and lap timingEach story builds its forge once, and all the forges are built in one
beforeAllat the same time. The #254 forge never starts its runtime, because only the page is under test. The two #36 apps deploy side by side.beforeAll, beside the chain, and its one test reads the settled result.startAppsForgetakes optional{ domain, concurrency, start }, and existing callers are unchanged. New helpers areappsRuntime(to build the replacement runtime after a restart) andsignedInCookie, which replaces three copies of the sign-in code.Each rewritten test still fails without the code it guards. I broke the source, ran only that test, and restored:
reseedEmpty(…)removed from the preview retrytrue, so production retries toostripForgeDirsreturns the line unchangedemail_offmarkers removed insrc/web/ui.tsthis.stopped && abort.signal.abortedbranch disabledfirst: productionset tofalseBreaking only the #296 boot loop is not enough to fail its test, and the test on main doesn't fail either. The gate's
first: production(src/apps/runtime.ts:1258) keeps production first by itself, so the ordering is guarded in two places. The test catches the order only when both are broken.Checks run:
bun scripts/gate.ts,bun x tsc --noEmit,test/apps.test.tsthree times in a row, and the 12 other suites that importtest/helpers/apps-forge.ts(44 pass, 0 fail). All green.Not done: I didn't add a fake clock. The remaining time is real process starts and health checks, which is what these tests prove, and the only waits left are 10 ms polls.
To try it:
bun test test/apps.test.ts, orbun test --reporter=junit --reporter-outfile=out.xml test/apps.test.tsfor per-test times.🤖 Generated with Claude Code
Closes #10244