3.3 KiB
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 testwas run once at HEAD39dc456and exited 0. The output was read throughtail, so the "Tests" line itself was not captured; the count 1390 in 132 files is the code summary's figure.git diff --stat 2006fa0 HEADshows no change outsideaidlc-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.tsis a Vitest global setup, used byvite.config.tsand byvitest.e2e.config.ts. It picks one seed per run (FC_SEEDif set, otherwise random) and always prints it, also when everything passes:fast-check seed: <n> (opnieuw: FC_SEED=<n> pnpm test).src/test/setup.tshands it tofc.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/configandweb/e2efinds noendOnFailureand 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
checkjob runspnpm test(the workflow comment says the seed is logged). Thelighthousejob runspnpm 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 (preloadImageinseo.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:
- Read the output; copy the printed seed and the shrunk counterexample.
- Replay with
FC_SEED=<seed> pnpm test(or one file withpnpm exec vitest run <file>). - Fix the code, or the test if the design rule changed, and rerun the whole suite.
- 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()andNot implemented: navigation to another Document.