Files
SluijsensandClaude Opus 5.5 069c7cb7eb Adds AI-DLC construction docs for the front-end shell feature
Functional design, NFR requirements, code generation plan and summary,
and build-and-test instructions with results.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 17:05:03 +02:00

35 lines
1.9 KiB
Markdown

# Unit Test Execution — frontend-shell
## Run the tests
```bash
pnpm test # once, with coverage
pnpm test:watch # while developing
```
## Expected results
- **18 test files, 82 tests, 0 failures.** That includes:
- **Property-based tests** (fast-check) for every row in "Testable Properties" of business-rules.md: `backToTopThreshold`, `visibleSocials`, `emailAddress`, `copyrightLine`, `canonicalUrl`, `sitemapXml`, `jsonLdScript`, `slidesToLoad`.
- **Example-based component tests** with React Testing Library.
- **axe-core accessibility checks** in the component and integration tests (colour contrast excluded in jsdom; Lighthouse covers it).
- **Coverage**: the run fails if any pure function in `src/lib/**`, `src/seo.ts` or `src/sitemap.ts` drops below 100% (statements, branches, functions, lines). For everything else coverage is reported only (overall ≈80% of lines).
- **Report**: in the terminal; an HTML report is written to `coverage/` (git-ignored).
## Property-based testing (PBT-08)
- **Seed**: every run prints one line, for example:
```
fast-check seed: 1344216500 (opnieuw: FC_SEED=1344216500 pnpm test)
```
The seed comes from `config/testSeed.ts` and applies to all property tests in that run.
- **Replay** a run exactly, failing or not:
```bash
FC_SEED=1344216500 pnpm test
```
- **On a failure** fast-check also reports the shrunk minimal counterexample and its `path`. Shrinking is on and never disabled.
- **Flaky failures** are not retried away. Replay with the seed, find the cause, fix it.
## Fixing failing tests
1. Read the failing test name and message in the terminal output.
2. For a property test: replay with `FC_SEED`, then turn the shrunk counterexample into an example test.
3. Fix the code, or the property if it was stated too broadly. An example from this feature: monotonicity of `backToTopThreshold` holds only for finite input, because BR-TOP-01 maps non-finite input to 0.
4. Rerun `pnpm test`.