Files

3.3 KiB

Unit Test Execution

Feature: prerendering. HEAD 39dc456.

Run Unit Tests

1. Execute All Unit Tests

cd web
pnpm test

pnpm test is vitest run --coverage. It runs the unit and component tests of all three units together, in jsdom. The browser tests are a separate command (pnpm e2e, see integration-test-instructions.md).

2. Review Test Results

  • Expected: 1390 tests in 132 files, 0 failures. This is the count of the unit 3 code summary (unit 1 ended at 1179, unit 2 at 1277, master had 888).
  • Confirmed in this stage: pnpm test was run once at HEAD 39dc456 and exited 0. The output was read through tail, so the "Tests" line itself was not captured; the count 1390 in 132 files is the code summary's figure. git diff --stat 2006fa0 HEAD shows no change outside aidlc-docs/, so the code is the code that count was taken on.
  • Test Coverage (v8, this run): statements 96.1% (1654/1721), branches 94.5% (1152/1219), functions 97.36% (518/532), lines 96.6% (1479/1531). The configured thresholds are met (the run exited 0).
  • Test Report Location: terminal output and web/coverage/ (gitignored).

3. Property-based tests (PBT-08)

  • Framework: fast-check, through Vitest.
  • Seed: web/config/testSeed.ts is a Vitest global setup, used by vite.config.ts and by vitest.e2e.config.ts. It picks one seed per run (FC_SEED if set, otherwise random) and always prints it, also when everything passes: fast-check seed: <n> (opnieuw: FC_SEED=<n> pnpm test). src/test/setup.ts hands it to fc.configureGlobal({ seed }), so every property in the run uses it.
  • Replay: FC_SEED=<seed> pnpm test. Seeds seen in this feature: 1405857762 (unit 1), 2056055883 (unit 2), 511446714 (unit 3), 753602326 (the browser run of CI run 599).
  • Shrinking: not disabled. A search of web/src, web/config and web/e2e finds no endOnFailure and no shrink override (the only "shrink" match is a CSS comment). On a failure fast-check prints the shrunk counterexample and the seed.
  • CI: the check job runs pnpm test (the workflow comment says the seed is logged). The lighthouse job runs pnpm e2e, which prints its own seed. Both runs therefore log a seed on every run.
  • Properties added by this feature: P1 to P9 (config/inlineScripts.test.ts), P10 (pageFiles), P11 to P13 (externalizeInlineScripts), P14 (contactChannels), P15 (emailAddress), P16 and P17 (previewServer), P18 to P21 (revealPhase), P22 (preloadImage in seo.ts), P24 and P25 (firstRow), P-HST-01 to 08 (canonicalUrls, previewServer, serverConfig), P-HST-09 (nginx against the preview server, bounded to 100 runs, in the browser suite), P-HST-11 (lighthouserc). P23 is an example test. Hooks and browser flows have example tests only (no property identified).

4. Fix Failing Tests

If tests fail:

  1. Read the output; copy the printed seed and the shrunk counterexample.
  2. Replay with FC_SEED=<seed> pnpm test (or one file with pnpm exec vitest run <file>).
  3. Fix the code, or the test if the design rule changed, and rerun the whole suite.
  4. A property that fails once and passes on retry is a defect to investigate (PBT-08), not noise.

Known messages (not failures)

  • jsdom prints Not implemented: HTMLCanvasElement's getContext() and Not implemented: navigation to another Document.