PACKAGE · TESTING

fast-check

Property based testing framework for JavaScript (like QuickCheck)

WEEKLY DOWNLOADS 48.1M
STARS 5.2K
FORKS 214
OPEN ISSUES 76
GZIP SIZE 58.8 kB
UNPACKED SIZE 1.5 MB
DEPENDENCIES 2
LAST UPDATED 9mo ago
DOWNLOAD TRENDS

fast-check downloads · last 12 months

Download trends for fast-check1 download series from Oct 2025 to Sep 2026. Use left and right arrow keys to inspect monthly values.043.1M86.2M129.3M172.5MOct 2025JanAprJulSep 2026
fast-check
ABOUT FAST-CHECK

fast-check is a property-based testing framework for JavaScript and TypeScript, inspired by Haskell's QuickCheck. It enables developers to test their code by defining properties that should hold true for a wide range of inputs, rather than enumerating specific test cases. The core problem it solves is the difficulty in anticipating all edge cases and complex input combinations that might cause software to fail, a common challenge in traditional example-based testing.

Its philosophy centers on generating inputs programmatically and exploring the input space to uncover bugs. This approach is particularly valuable for developers building robust libraries or complex business logic where unexpected input can lead to subtle, hard-to-find defects. It aims to provide a more comprehensive and scalable testing strategy than manually written unit tests.

The framework's key API patterns involve defining arbitraries, which are generators for specific data types like numbers, strings, or custom objects, and then asserting properties using `fc.assert()`. Developers can combine arbitraries, shrink generated values upon failure, and use specialized generators for complex structures like arrays, maps, or JSON.

fast-check integrates seamlessly into existing testing workflows, commonly used with testing runners like Jest or Mocha. It can be employed in any JavaScript or TypeScript project, especially those prioritizing code correctness and resilience. Its TypeScript support enhances developer experience through strong typing and autocompletion for arbitraries and properties.

With 5.1K GitHub stars and 30.0M weekly downloads, fast-check is a mature and widely adopted testing tool. The library's unpacked size is 1.5 MB, with a gzipped bundle size of 58.8 kB, making it a reasonable addition to development dependencies without significantly impacting build times.

One potential consideration is the learning curve associated with mastering property-based testing concepts, which differ from traditional testing. Developers need to think about input generation and property definitions, which may require a shift in testing mindset for those new to the paradigm.

WHEN TO USE
  • When designing APIs where input validation is critical and complex.
  • To uncover edge cases in algorithms involving permutations, combinations, or recursive structures.
  • When testing functions that process structured data like JSON or custom object graphs.
  • To verify that transformations between data formats remain consistent for all valid inputs.
  • When seeking to improve the robustness of parsing logic or serialization routines.
  • To automatically explore a vast range of inputs for business logic that handles financial calculations or state management.
WHEN NOT TO USE
  • If your primary need is simple smoke testing of UI components with predefined states.
  • When your codebase relies solely on straightforward input-output mappings that are exhaustively covered by examples.
  • If you are seeking a minimal testing utility with no generative capabilities.
  • When your project lacks TypeScript support and the type safety benefits are not a priority.
  • For testing external API integrations where the number of possible inputs is effectively infinite and unpredictable.

CORRECTIONS

Spot wrong data here?

A short note helps us fix it.

Anonymous · No account · No email back

COMPARISONS 11
fast-check vs @testing-library/react ★ 19.7K · 62.2M/wk fast-check vs jasmine-core ★ 15.8K · 5.1M/wk fast-check vs mocha ★ 22.9K · 13.3M/wk fast-check vs jest ★ 45.5K · 46.0M/wk fast-check vs nightwatch ★ 12.0K · 103.8K/wk fast-check vs selenium-webdriver ★ 34.5K · 1.8M/wk fast-check vs vitest ★ 17.2K · 111.4M/wk fast-check vs playwright ★ 97.0K · 104.1M/wk fast-check vs chai ★ 8.3K · 126.7M/wk fast-check vs cypress ★ 51.0K · 6.0M/wk fast-check vs ava ★ 20.8K · 456.2K/wk