← ClaudeAtlas

property-based-testinglisted

Use when writing, reviewing, or modifying property-based tests, such as those using `fast-check`, or when asked to add test coverage.
TomerAberbach/claude-config · ★ 0 · Testing & QA · score 73
Install: claude install-skill TomerAberbach/claude-config
Before starting, read: `../authoring-tests/SKILL.md` Adhere to these principles when writing property-based tests: - Write focused properties with focused arbitraries to properly explore slices of the input space. - Prefer arbitraries that generate the desired input space directly instead of generating a larger input space and then filtering it down. - Keep assertions focused only on what's straightforward to infer from the input arbitraries. It's often infeasible assert the full value. If no assertion seems feasible, then the input space is too broad. - NEVER unnecessarily constrain an arbitrary. Only add constraints if it's necessary to satisfy the property or resolve performance problems. # Common properties - "Output is always/never X for all inputs". Example: for any number `n`, `Math.floor(n)` is an integer. - "When input is X, then output is always/never Y". Example: for any array `data` with no duplicates, the result of removing duplicates from `data` is `data` itself. - "Complex implementation X is equivalent to simpler implementation Y". Example: "`c` is contained inside sorted array `data` for binary search" is equivalent to "`c` is contained inside `data` for linear search". - Totality: function returns (doesn't throw) for all valid inputs. Example: `JSON.parse(JSON.stringify(x))` never throws for serializable `x`. - Deterministic: always returns the same output for the same input. Example: for any date `d`, `formatDate(d)` alway