Skip to content

Commit 8670a88

Browse files
test: property-based testing foundation (fast-check) over parse/print and geometry kernels (#1437)
* test: property-based testing foundation over parse/print and geometry kernels (#1413) Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test: derive selector and replay command domains from their owning registries Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: Michał Pierzchała <[email protected]> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent e8b779c commit 8670a88

11 files changed

Lines changed: 738 additions & 3 deletions

File tree

‎docs/agents/testing.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,22 @@ to make a test easier — widening the public surface for a test is a product ch
4848
outlive the test that motivated them. If a seam is genuinely missing, add it as a real one rather
4949
than as a test affordance (the workflow separately forbids test-only `typeof` DI params).
5050

51+
## Properties over examples (pure parsers and geometry)
52+
53+
**Pure parser or geometry change → extend a property, not another example.** The parse/print and
54+
geometry kernels (selectors, `@eN~sM` refs, `.ad` script lines, gesture planning, snapshot diff) are
55+
covered by fast-check properties living in each owning module's test file. Their generators are
56+
shared in `src/__tests__/test-utils/property-arbitraries.ts` and exported through the test-utils
57+
barrel, so a new hazard (another quote shape, a new gesture kind, another `.ad` command) belongs in
58+
the generator, where every property inherits it — not in a new hand-pinned case.
59+
60+
- Keep examples that document a specific decision or a real past bug; add the general guarantee as a
61+
property alongside them.
62+
- Bound `numRuns` with the shared `PROPERTY_RUNS` / `PROPERTY_RUNS_SMALL` constants: properties run
63+
in `unit-core` under the same slow-test budget as everything else.
64+
- A failing property prints the shrunk counterexample plus the seed and path to replay it; paste
65+
that seed into `fc.assert(..., { seed, path })` to re-run exactly that case.
66+
5167
## Affected-check selector (`pnpm check:affected`)
5268

5369
`pnpm check:affected --base <ref>` derives which local checks a diff needs, so

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@
231231
"@types/node": "^22.19.21",
232232
"@vitest/coverage-v8": "4.1.8",
233233
"fallow": "^2.95.0",
234+
"fast-check": "^4.9.0",
234235
"oxc-parser": "^0.138.0",
235236
"oxfmt": "^0.42.0",
236237
"oxlint": "^1.69.0",

‎pnpm-lock.yaml‎

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/__tests__/test-utils/index.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ export {
2828

2929
export { makeSessionStore } from './store-factory.ts';
3030

31+
export {
32+
COMPACT_VIEWPORTS,
33+
formatRef,
34+
formatSelectorChainExpression,
35+
gestureInViewportArb,
36+
PROPERTY_RUNS,
37+
PROPERTY_RUNS_SMALL,
38+
rawSnapshotNodesArb,
39+
refArb,
40+
replayScriptArb,
41+
selectorChainArb,
42+
} from './property-arbitraries.ts';
43+
3144
export { withNoColor } from './color.ts';
3245

3346
export {

0 commit comments

Comments
 (0)