fast-check generates random inputs to test properties of JavaScript or TypeScript code, with shrinking, custom arbitraries, and runners for Jest, Mocha, and other frameworks.
Overview
fast-check brings QuickCheck-style property testing to JavaScript and TypeScript projects. Developers state properties that should hold for all inputs meeting preconditions, and the library searches for counterexamples while shrinking failing cases.
Built-in arbitraries cover common data types, and combinators such as map, chain, and oneof extend generation while preserving shrink behavior. Features include biased sampling, verbose logging, race-condition detection helpers, and integration examples for major test runners.
The package ships typed APIs for modern TypeScript versions and documents version-specific Node and ECMAScript requirements. It is widely used in ecosystem projects and has historically helped uncover bugs in open source libraries.
Installation is via standard package managers as a development dependency, with tutorials and an online sandbox for first experiments.
Key features
- Property and arbitrary API
- Counterexample shrinking
- Custom arbitrary combinators
- Runner integrations
- Race condition detection helpers
- Strong TypeScript typings
- Verbose debug logging
- Built-in data generators
Use cases
- Fuzzing pure functions
- Regression-resistant unit tests
- Finding edge-case bugs
- Testing serialization invariants