Framework
dubzzz/fast-check avatar
dubzzz/fast-check

fast-check: property-based testing for JavaScript and TypeScript

Property based testing framework for JavaScript (like QuickCheck) written in TypeScript

5,297 stars218 forksTypeScriptMIT

At a glance

What is it?
fast-check generates inputs from properties instead of hand-written cases, and shrinks any counterexample it finds. It fits teams already running Jest or Vitest who want generated coverage, not a replacement test runner.
Who is it for?
Adopt fast-check if you already run Jest, Vitest, Mocha, Ava, Jasmine or Tape and have pure functions or state machines whose invariants you can state in words. Skip it if your logic is mostly I/O, timing or third-party behaviour, where generated inputs mostly reproduce what integration tests already cover.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository received new commits within the last day.
What is it written in?
Mainly TypeScript, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 22, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • dubzzz/fast-check5,297 ★ · +144
Star history
Repository2026-09-232026-11-22
dubzzz/fast-check5.2k5.3k

144 Stars in the last 60 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

The problem fast-check solves: examples do not cover input space

A hand-written unit test asserts one input and one output. That is fine until the bug lives in a boundary you did not think of: an empty string, a string containing its own separator, a negative zero, an array where two elements are equal. fast-check inverts the workflow. You state a property, meaning a statement of the form "for all x, y such that a precondition holds, a predicate is true", and the library generates the inputs, runs the predicate, and reports a counterexample when it fails. The repository description frames the project this way: a property based testing framework for JavaScript, like QuickCheck, written in TypeScript.

The intended audience is JavaScript and TypeScript developers who already have a test runner. The repository ships an examples directory with numbered folders including 001-simple, 002-recursive, 003-misc, 004-stateMachine and 005-race. That list is a fair summary of where the approach pays off: recursive data structures, state machines, and concurrent or racing behaviour. It is a library, not a runner, so it slots into whatever you already use.

Arbitraries, properties and shrinking: the actual mechanism

Two types carry the design. An arbitrary describes how to generate values of some type, and a property combines arbitraries with a predicate. fc.string() is an arbitrary; fc.property(fc.string(), (text) => contains(text, text)) is a property. fc.assert runs it and throws on failure.

Shrinking is the second half. When a predicate fails, fast-check searches for a smaller input that still fails and reports that. The seed and path are the reproduction handle; the shrunk values are the diagnosis.

Extending an arbitrary keeps the shrinker, which is the part most generators get wrong.

Installing fast-check and writing a first property

Install it as a development dependency with the package manager you already use.

bash
npm install fast-check --save-dev
js
text

Where fast-check is the wrong tool

Generated inputs are only as good as the property you can write. If the correct behaviour is "this HTTP call returns 200 and the row appears in the database", there is no useful for-all statement, and fast-check adds ceremony without adding coverage. Integration and end-to-end tests remain the right instrument there.

Timing is a second boundary. The recent v4.10.1 release is titled "Fix fake-timer compatibility in timeout and interrupt plugins", which is a reminder that the interaction between generated async work and fake timers has needed patching. If your code is dominated by timers, retries and scheduling, expect to spend time on the harness rather than on the property.

Third, shrinking is a search, not a guarantee. For a predicate with a narrow precondition, most generated values may be discarded, and the run gets slower without getting more informative.

Finally, an async API surface has a cost. The project ships a 005-race example. That is a signal that concurrent properties are supported and also that they are where the sharp edges are.

fast-check versus Vitest and Jest

These are not competing choices. Vitest and Jest are test runners: they discover files, execute test cases, and report pass or fail. fast-check is a generator and a shrinker that runs inside a test case. The repository has a fast-check/vitest relationship in its own tooling: the monorepo's test script is vitest and the workspace includes a vitest.config.mjs.

The real alternative is a fuzzer or a hand-rolled random-input loop. A loop that calls Math.random and retries on failure gives you no shrinking and no seed, so a failure you cannot reproduce is a failure you cannot fix. fast-check's difference is the shrink step plus the seed and path in the report. If you already have Jest or Vitest, the practical decision is not which runner to use but which functions in your codebase have a statable invariant worth generating inputs for.

Maintenance, releases and the MIT licence

The repository is not archived and the last push was on 2026-11-01. Recent releases include v4.10.1 on 2026-09-15, which fixed fake-timer compatibility in timeout and interrupt plugins, and v4.10.2 on 2026-09-19. The changelog is managed with Changesets, visible in the .changeset directory and the bump and changelog scripts in the root package.json.

The version number in your package.json is the thing to pin deliberately. The monorepo itself requires pnpm 12.16.1 per the devEngines block, but that governs contributing to fast-check, not consuming it.

The licence is MIT, which permits commercial and closed-source use. That is a statement about the licence text, not legal advice; check it against your own distribution requirements.

Editorial conclusion

Adopt fast-check if you already run Jest, Vitest, Mocha, Ava, Jasmine or Tape and have pure functions or state machines whose invariants you can state in words. Skip it if your logic is mostly I/O, timing or third-party behaviour, where generated inputs mostly reproduce what integration tests already cover. Before committing, run one property against a function you know is correct, then deliberately break it and read the shrunk counterexample and the seed it prints, because that report is what you will live with on every future failure.

Frequently asked questions

What is fast-check?

fast-check is a property-based testing framework for JavaScript and TypeScript, written in TypeScript and modelled on QuickCheck. Instead of asserting single examples, you state properties and it generates inputs to try to falsify them.

How does property-based testing work?

You combine arbitraries, which describe how to generate values, with a predicate using fc.property, and run it with fc.assert. On failure fast-check shrinks the input to a smaller failing case and reports a seed and path for reproduction.

What is the fast-check npm package?

It is the published package for the library, installed as a development dependency with npm install fast-check --save-dev.

Is fast-check a replacement for Vitest?

No. Vitest is a test runner that discovers and executes tests; fast-check is a library that runs inside a test case.

Is fast-check a replacement for Jest?

No. Jest is a test runner, while fast-check generates and shrinks inputs inside a test case.

Official sources

  1. dubzzz/fast-check on GitHub
  2. License: MIT
  3. Project website
  4. README
  5. Releases
Community

Where developers are discussing it

Posts on Hacker News, dev.to and Lobsters that link to this repository, found by our scan of those communities. 1 in the last 30 days; newest first.

Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/dubzzz-fast-check.svg)](https://hysenlabs.com/projects/dubzzz-fast-check)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/dubzzz-fast-check.svg)](https://hysenlabs.com/projects/dubzzz-fast-check)

Was this useful?