Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
fc
✓ import fc from 'fast-check';
✗ const fc = require('fast-check').default;
The primary way to import the main library. While fast-check itself supports both ESM and CJS in v4, many of its adapter packages are ESM-only.
assert
✓ import { assert, property, string } from 'fast-check';
✗ import fc, { assert, property } from 'fast-check';
`assert` and `property` are named exports for core testing logic, typically used alongside `fc`'s default export.
test
✓ import { test } from '@fast-check/vitest';
✗ const { test } = require('@fast-check/vitest');
Adapter packages like `@fast-check/vitest` (and `@fast-check/worker`, etc.) are ESM-only since their v0.3.0+ (or equivalent) releases.
Demonstrates a basic integration of fast-check with Mocha, defining and asserting properties using arbitrary string generation.
import fc from 'fast-check';
// Code under test
const contains = (text, pattern) => text.indexOf(pattern) >= 0;
// Properties
describe('properties', () => {
// string text always contains itself
it('should always contain itself', () => {
fc.assert(fc.property(fc.string(), (text) => contains(text, text)));
});
// string a + b + c always contains b, whatever the values of a, b and c
it('should always contain its substrings', () => {
fc.assert(
fc.property(fc.string(), fc.string(), fc.string(), (a, b, c) => {
// Alternatively: no return statement and direct usage of expect or assert
return contains(a + b + c, b);
}),
);
});
});
Debug
Known issues
breakingSeveral adapter packages (e.g., `@fast-check/worker`, `@fast-check/vitest`, `@fast-check/poisoning`, `@fast-check/packaged`, `@fast-check/ava`) have dropped CommonJS support and are now ESM-only. If you are using these integrations, you must update your project to use ES modules (`import`/`export`).fixMigrate your project to use ES module syntax (e.g., `import { test } from '@fast-check/vitest';`) and ensure your Node.js environment is configured for ESM. affects: >=@fast-check/{worker,poisoning,packaged}/v0.6.0, >=@fast-check/{vitest,ava}/v3.0.0
deprecatedThe methods `Random::next(n)` and `Random::nextInt()` have been deprecated. Users should migrate to newer alternatives for random number generation.fixConsult the fast-check documentation for the recommended alternatives to `Random::next(n)` and `Random::nextInt()`.
affects: >=4.6.0
gotchaWhile the core `fast-check` package in the 4.x series still supports CommonJS (`require()`), many of its ecosystem adapter packages (e.g., for Vitest, Ava, Workers) have moved to ESM-only. This can lead to module resolution issues if mixing CommonJS for `fast-check` and ESM-only adapters.fixFor consistency and to avoid module conflicts, it is recommended to use ESM throughout your project when integrating with the latest versions of fast-check adapter packages.
affects: >=4.x (core) combined with >=adapter@v0.3.0/v0.6.0/v3.0.0
Errors
Common errors & fixes
Error: Property failed by returning false
A property's predicate function returned `false` for a generated input, indicating a bug in the code under test or the property definition.
fixReview the counterexample provided in the test output (the shrunken inputs) to debug your implementation or refine your property's preconditions.
SyntaxError: Cannot use import statement outside a module
Attempting to use ES module `import` syntax in a CommonJS context, especially common when using ESM-only adapter packages like `@fast-check/vitest`.
fixEnsure your file is treated as an ES module (e.g., by using `.mjs` extension, or setting `"type": "module"` in `package.json`) or migrate to using `require()` if the package still supports CJS and you must use CJS.
Audit
Dependencies
No dependency data recorded yet.