PACKAGE · TESTING

fast-check

Property based testing framework for JavaScript (like QuickCheck)

WEEKLY DOWNLOADS 11.2M
STARS 5.0K
FORKS 209
OPEN ISSUES 83
GZIP SIZE 56.7 kB
UNPACKED SIZE 1.4 MB
DEPENDENCIES 2
LAST UPDATED 5mo ago
DOWNLOAD TRENDS

fast-check downloads — last 12 months

Download trends for fast-check1 download series from Jun 2025 to May 2026. Use left and right arrow keys to inspect monthly values.018.7M37.5M56.2M74.9MJun 2025SepDecMarMay 2026
fast-check
ABOUT FAST-CHECK

fast-check is a property-based testing framework for JavaScript, inspired by QuickCheck. It addresses the challenge of finding edge cases and unforeseen bugs in code that traditional, specific test cases might miss. By defining properties that should hold true for all possible inputs, developers can automatically generate a vast range of test data, ensuring greater code robustness and reliability.

The core philosophy of fast-check revolves around defining constraints and properties rather than explicit examples. Its primary audience includes developers building complex logic, particularly those working with functional programming paradigms or intricate state management. The framework aims to shift testing focus from *what* to test to *how* the code should behave under various conditions, leading to more comprehensive test suites.

Key API patterns include the `fc.property` function, which takes one or more arbitraries and a predicate function. Arbitraries, like `fc.integer()`, `fc.string()`, or `fc.array()`, define how test data is generated. Advanced features like `fc.context()`, `fc.uniqueArray()`, and custom arbitraries allow for fine-grained control over test data generation, enabling the exploration of complex input spaces and data structures.

fast-check integrates seamlessly into standard JavaScript testing workflows. It can be used with popular test runners like Jest, Mocha, and Vitest. The framework's `async` support makes it compatible with asynchronous code, and its compatibility with TypeScript ensures type safety during test development, fitting well into modern development pipelines.

With 15.8 million weekly downloads and 4.9K GitHub stars, fast-check is a mature and widely-used library in the testing ecosystem. Its unpacked size is 1.4 MB, with a gzipped bundle size of 56.7 kB, making it a reasonably lightweight addition to a project's testing dependencies. The active development, indicated by its recent updates, suggests a well-maintained and evolving tool.

Developers should be aware that mastering property-based testing requires a shift in mindset from example-based testing. While powerful, the initial learning curve for defining effective properties and arbitraries can be steep. For very simple functions with minimal input complexity, the overhead of setting up property-based tests might outweigh the benefits compared to traditional unit tests.

WHEN TO USE
  • When generating random, varied input data for functions to discover edge cases in string manipulation or array processing.
  • When testing algorithms that operate on complex data structures, leveraging custom arbitraries to model specific schemas.
  • When verifying invariants or essential properties of business logic, such as ensuring a sorting function never alters the original array's elements.
  • When integrating into existing Jest or Vitest test suites to enhance coverage with property-based approaches.
  • When dealing with asynchronous operations or promise-based code, utilizing `fc.asyncProperty` to test reliably.
  • When implementing code that needs to be resilient to malformed or unexpected inputs, common in API endpoints or user interfaces.
WHEN NOT TO USE
  • If your primary need is to test UI interactions across multiple components; a dedicated end-to-end framework might be more appropriate.
  • If you are only testing simple, deterministic mathematical formulas where specific known inputs and outputs are sufficient; traditional unit tests are more direct.
  • If your project has extreme constraints on build size and the 56.7 kB (gzip) bundle size is a critical factor; consider lighter assertion libraries without generative capabilities.
  • When migrating a large, existing test suite composed solely of example-based tests, the effort to refactor to property-based testing might be prohibitive without a clear benefit.
  • If the data structures involved are exceptionally simple key-value pairs; native JavaScript or simpler state management patterns might suffice over complex generative approaches.

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.6K · 21.3M/wk fast-check vs nightwatch ★ 11.9K · 56.7K/wk fast-check vs cypress ★ 49.7K · 3.4M/wk fast-check vs vitest ★ 16.6K · 33.1M/wk fast-check vs playwright ★ 90.4K · 29.2M/wk fast-check vs jest ★ 45.4K · 21.7M/wk fast-check vs selenium-webdriver ★ 34.2K · 933.9K/wk fast-check vs chai ★ 8.3K · 38.8M/wk fast-check vs jasmine-core ★ 15.8K · 2.6M/wk fast-check vs mocha ★ 22.9K · 6.7M/wk fast-check vs ava ★ 20.9K · 288.3K/wk