Skip to content

Commit 5d82f23

Browse files
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 PBT
1 parent 149c5c0 commit 5d82f23

File tree

6 files changed

+488
-214
lines changed

6 files changed

+488
-214
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"devDependencies": {
6060
"@ai-sdk/provider": "catalog:dev",
6161
"@ai-sdk/provider-utils": "catalog:dev",
62+
"@fast-check/vitest": "catalog:dev",
6263
"@hono/mcp": "catalog:dev",
6364
"@types/node": "catalog:dev",
6465
"@typescript/native-preview": "catalog:dev",

pnpm-lock.yaml

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

pnpm-workspace.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ catalogs:
88
dev:
99
'@ai-sdk/openai': ^2.0.80
1010
'@ai-sdk/provider': ^2.0.0
11+
'@fast-check/vitest': ^0.2.0
1112
'@ai-sdk/provider-utils': ^3.0.18
1213
'@clack/prompts': ^0.11.0
1314
'@hono/mcp': ^0.1.4

0 commit comments

Comments
 (0)