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

Merged opened this

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

Merged

mason/forge:mason/3670-a-new-app-s-own-test-suite-runs-in-under → main 1 commit fork 2 threads · 2 unresolved

  • Merged. mason/3670-a-new-app-s-own-test-suite-runs-in-under was merged into main as 3a9599d.

Review

Sign in to review this change.
2 files changed +15 −4
docs/APPS.md +5 −3
@@ -539,9 +539,11 @@ returns through `audited`, every API route carries its description, no
539539 colour is spelled out, and the door is never routed around.
540540 `test/scaffold.test.ts` writes the scaffold out and runs its suite and its
541541 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](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.

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.

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](CONTRACT.md)).
545547
546548 ## Who is there: identity from the forge
547549
test/scaffold.test.ts +10 −1
@@ -25,6 +25,9 @@ import { createUser } from "../src/core/users.ts";
2525 import { serve } from "../src/http/server.ts";
2626 import { scaffoldFiles } from "../src/apps/scaffold.ts";
2727
28 /** How long the written-out app's `bun test` may take, wall clock. */
29 const SUITE_BUDGET_MS = 3_000;
30
2831 /** A child that inherits nothing it was not handed. */
2932 const run = async (
3033 cwd: string,
@@ -68,9 +71,15 @@ describe("a scaffolded app, written out and run on its own", () => {
6871 });
6972 afterAll(() => rm(dir, { recursive: true, force: true }));
7073
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();
7278 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.

7381 expect([code, out.includes(" 0 fail")]).toEqual([0, true]);
82 expect(ms).toBeLessThanOrEqual(SUITE_BUDGET_MS);
7483 // Each guarantee has its own file of tests in the suite.
7584 for (const name of [
7685 "design.test.ts",

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs