Commit 5d82f23
authored
feat(test): add property-based testing with @fast-check/vitest (#266)
* chore(deps): add @fast-check/vitest for property-based testing
- Add @fast-check/vitest ^0.2.0 to dev catalog
- Enables native vitest integration for PBT
* test(tfidf-index): add property-based tests with @fast-check/vitest
- Verify scores are always within [0, 1] range
- Verify results are sorted by score in descending order
- Verify search returns at most k results
- Verify case-insensitive search produces consistent results
- Verify empty corpus always returns empty results
- Verify result IDs are from the indexed corpus
- Verify search is deterministic
* test(array): replace example-based tests with PBT
- Verify array input returns same reference
- Verify non-array non-nullish input wraps in single-element array
- Verify null/undefined returns empty array
- Verify result is always an array
Property-based tests cover all original cases and more edge cases.
* test(requestBuilder): add property-based tests for edge cases
- Test parameter key validation (valid/invalid characters)
- Test header management (accumulation, User-Agent, immutability)
- Test value serialization (strings, integers, booleans, arrays)
- Test deep object nesting within depth limits
- Test body type handling for all supported types
PBT improves coverage of boundary conditions and error paths.
* refactor(test): remove redundant tests now covered by PBT
- Remove depth limit test from requestBuilder (covered by PBT)
- Remove invalid key validation test (covered by PBT)
- Remove array serialization test (covered by PBT)
- Clean up tfidf-index tests: remove Score Validation, Edge Cases,
Case Sensitivity, and Search Limits sections (all covered by PBT)
Coverage maintained at 92.45% statements, 93.47% lines.
Branch coverage improved from 83.98% to 84.43%.
* docs(test): add documentation comments to PBT explaining replaced tests
- Add JSDoc comments explaining what example-based tests were replaced
- Add inline comments with concrete examples for each property test
- Restore 'should handle arrays correctly within objects' test for clarity
- Keep concrete examples as documentation alongside PBT1 parent 149c5c0 commit 5d82f23
File tree
6 files changed
+488
-214
lines changed- src
- utils
6 files changed
+488
-214
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
0 commit comments