typefuzz
v1.0.0
Published
TypeScript fuzz/property testing utilities with test runner integrations
Maintainers
Readme
TypeFuzz
Property-based testing for TypeScript that drops straight into your existing test runner. No wrappers, no config — write fuzz tests like you write unit tests.
Why TypeFuzz?
- Test runner integration —
fuzzItworks likeit/testinside Vitest and Jest. No separate CLI. - Zero dependencies — ships nothing you don't need. Vitest, Jest, and Zod are optional peer deps.
- TypeScript-first — full type inference from generators to predicates. No casting.
- Deterministic — seeded RNG means every failure is reproducible with a single seed value.
- Built-in shrinking — automatic counterexample minimisation using binary search, length reduction, and delta debugging.
Install
npm install -D typefuzzpnpm add -D typefuzz
yarn add -D typefuzz
bun add -D typefuzzQuick example
import { fuzzIt } from 'typefuzz/vitest';
import { gen } from 'typefuzz';
fuzzIt('sort is idempotent', gen.array(gen.int(-100, 100), { minLength: 0, maxLength: 50 }), (arr) => {
const sorted = [...arr].sort((a, b) => a - b);
const sortedTwice = [...sorted].sort((a, b) => a - b);
return JSON.stringify(sorted) === JSON.stringify(sortedTwice);
});If the property fails, TypeFuzz shrinks the input to the smallest counterexample and prints the seed for replay.
TypeFuzz vs fast-check
| | TypeFuzz | fast-check |
| --- | --- | --- |
| Test runner integration | fuzzIt — one function, same signature as it | @fast-check/vitest with test.prop |
| API surface | Small, opinionated | Large, highly configurable |
| Shrinking | Binary search + delta debugging | Shrink-on-generate |
| Model-based testing | Built-in | Built-in |
| Zod integration | typefuzz/zod adapter | Community zod-fast-check |
| Async support | Native | Native |
Features
Model-based testing
Test stateful systems against a simplified model. TypeFuzz generates random command sequences, runs them against both your system and the model, and shrinks failing sequences to the shortest reproduction. Read more →
Zod adapter
Already have Zod schemas? Generate test data directly from them with zodArbitrary. Supports objects, arrays, unions, discriminated unions, transforms, and more. Read more →
Shrinking
When a property fails, TypeFuzz automatically minimises the counterexample — binary search for numbers, length halving for strings and arrays, delta debugging for model-based command sequences. Read more →
Documentation
- Documentation Index
- Getting Started
- Generators
- Core API
- Test Runner Integrations
- Model-Based Testing
- Zod Adapter
- Shrinking and Replay
- FAQ
- Releasing
- AI Testing Playbook
- AI Agent Compatibility
- Agent Instructions
- LLM Index
Development
bun install
bun run lint
bun run typecheck
bun run test