Public: anyone can read this; the crew can change it.
A new app's own test suite runs in under 3 s, and test/scaffold.test.ts holds it there #3733
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/3670-a-new-app-s-own-test-suite-runs-in-under → main 1 commit fork 2 threads · 2 unresolved
2 files
changed +15
−4
docs/APPS.md +5 −3
| @@ -539,9 +539,11 @@ returns through `audited`, every API route carries its description, no | ||
| 539 | 539 | colour is spelled out, and the door is never routed around. |
| 540 | 540 | `test/scaffold.test.ts` writes the scaffold out and runs its suite and its |
| 541 | 541 | two scripts, so a change to the scaffold that breaks one of these does |
| 542 | not land. The table the door reads knows two signed identities, `user` | |
| 543 | and `admin`; a role such as a team's (`manage`) waits on the forge | |
| 544 | signing one (see [](CONTRACT.md)). | |
| 542 | not land. | |
| 543 | The app's own `bun test` has a budget of 3 s, because every deploy and every pull on the app waits for it; `test/scaffold.test.ts` times it and fails above that. | |
| 544 | The table the door reads knows two signed identities, `user` and | |
| 545 | `admin`; a role such as a team's (`manage`) waits on the forge signing | |
| 546 | one (see [](CONTRACT.md)). | |
| 545 | 547 | |
| 546 | 548 | ## Who is there: identity from the forge |
| 547 | 549 |
test/scaffold.test.ts +10 −1
| @@ -25,6 +25,9 @@ import { createUser } from "../src/core/users.ts"; | ||
| 25 | 25 | import { serve } from "../src/http/server.ts"; |
| 26 | 26 | import { scaffoldFiles } from "../src/apps/scaffold.ts"; |
| 27 | 27 | |
| 28 | /** How long the written-out app's `bun test` may take, wall clock. */ | |
| 29 | const SUITE_BUDGET_MS = 3_000; | |
| 30 | ||
| 28 | 31 | /** A child that inherits nothing it was not handed. */ |
| 29 | 32 | const run = async ( |
| 30 | 33 | cwd: string, |
| @@ -68,9 +71,15 @@ describe("a scaffolded app, written out and run on its own", () => { | ||
| 68 | 71 | }); |
| 69 | 72 | afterAll(() => rm(dir, { recursive: true, force: true })); |
| 70 | 73 | |
| 71 | test("its own suite is green", async () => { | |
| 74 | test("its own suite is green, inside its 3 s budget", async () => { | |
| 75 | // Every deploy and every pull on the app waits on this suite, so it is | |
| 76 | // held to a budget (docs/APPS.md, "What a new app starts as"). | |
| 77 | const started = performance.now(); | |
| 72 | 78 | const { code, out } = await run(dir, [process.execPath, "test"]); |
| 79 | const ms = Math.round(performance.now() - started); | |
| 80 | console.log(`the scaffold's own suite ran in ${ms} ms (budget ${SUITE_BUDGET_MS} ms)`); | |
The console.log adds a line to every green run. Useful while the budget is new; consider dropping it once the number is trusted, or print it only on failure by putting ms in the expect message. |
||
| 73 | 81 | expect([code, out.includes(" 0 fail")]).toEqual([0, true]); |
| 82 | expect(ms).toBeLessThanOrEqual(SUITE_BUDGET_MS); | |
| 74 | 83 | // Each guarantee has its own file of tests in the suite. |
| 75 | 84 | for (const name of [ |
| 76 | 85 | "design.test.ts", |
new above
offline
This line is unwrapped while the rest of the file is wrapped near 72 columns, and it forced the next paragraph to be re-flowed. Wrap it to keep the diff small.