Skip to main content

🌱 Ecosystem

Bring additional capabilities to fast-check by leveraging its rich ecosystem of extensions and plugins

Stability

This page provides a list of packages available in the fast-check ecosystem. It includes both official and third-party packages. While we can ensure the stability, usage, and maintenance of the official packages, we cannot provide any specific details or guarantees regarding the non-official packages.

Follow the emojis — last update January 2024
  • ⭐ official package
  • 🌗 official package with limited support
  • 🥇 active1 non-official package with many downloads2
  • 🥈 active1 non-official package
  • ⚠️ others

1: The package has been updated in the last twelve months
2: The package has been downloaded more than 1k times per month

In each section, packages marked with ⭐ and 🥇 will come first in alphabetical order, followed by 🥈 and then 🌗 and ⚠️.

Connectors

Create arbitraries based on other libraries.

For instance:

  • Many data validators enable you to define and sometimes validate runtime values and obtain accurate TypeScript types. With these packages, they can also be utilized to derive arbitraries that can be seamlessly plugged within fast-check.
  • Many fake data libraries come with powerful random and seeded generators, why don't you use them as arbitraries to ease migration path to full property-based testing?

@effect/schema 🥇

npm version monthly downloads last commit license third party package

Generate random values that conform to a given Schema. It allows you to generate random test data that is guaranteed to be valid according to the Schema.

import * as Arbitrary from '@effect/schema/Arbitrary';
import * as S from '@effect/schema/Schema';
import * as fc from 'fast-check';

const Person = S.struct({
name: S.string,
age: S.string.pipe(S.compose(S.NumberFromString), S.int()),
});
const isPerson = S.is(Person);
const personArbitrary = Arbitrary.make(Person)(fc);

test('Only generating valid Person', () => {
fc.assert(
fc.property(personArbitrary, (person) => {
expect(isPerson(person)).toBe(true);
}),
);
});

More details on the package itself!

zod-fast-check 🥇

npm version monthly downloads last commit license third party package

Convert zod validators into arbitraries for fast-check.

import * as z from 'zod';
import * as fc from 'fast-check';
import { ZodFastCheck } from 'zod-fast-check';

const User = z.object({ firstName: z.string(), lastName: z.string() });
const userArbitrary = ZodFastCheck().inputOf(User);

test("User's full name always contains their first and last names", () => {
fc.assert(
fc.property(userArbitrary, (user) => {
const parsedUser = User.parse(user);
const fullName = `${parsedUser.firstName} ${parsedUser.lastName}`;
expect(fullName).toContain(user.firstName);
expect(fullName).toContain(user.lastName);
}),
);
});

More details on the package itself!

fast-check-io-ts 🥈

npm version monthly downloads last commit license third party package

Convert io-ts validators into arbitraries for fast-check.
More details on the package itself!

graphql-codegen-fast-check ⚠️

npm version monthly downloads last commit license third party package

Convert GraphQL schemas into arbitraries for fast-check.
More details on the package itself!

json-schema-fast-check ⚠️

npm version monthly downloads last commit license third party package

Convert JSON Schemas into arbitraries for fast-check.
More details on the package itself!

idonttrustlikethat-fast-check ⚠️

npm version monthly downloads last commit license third party package

Convert idonttrustlikethat validators into arbitraries for fast-check.
More details on the package itself!

mock-data-gen ⚠️

npm version monthly downloads last commit license third party package

Convert io-ts validators into arbitraries for fast-check.
More details on the package itself!

jsverify-to-fast-check 🌗

npm version monthly downloads last commit license official package

Ease your migration path to fast-check by easily converting the arbitraries you defined for jsverify into some for fast-check. While still maintained, we do not work actively on this project given the current state of jsverify: last released in 2018.

import { jsc2fc } from 'jsverify-to-fast-check';
import * as jsc from 'jsverify';
import * as fc from 'fast-check';

// Here is an old arbitrary you prefer not to migrate for the moment
const jscArbitrary = jsc.bless({
generator: jsc.generator.bless(() => {
switch (jsc.random(0, 2)) {
case 0:
return 'foo';
case 1:
return 'bar';
case 2:
return 'quux';
}
}),
});

// It can easily converted into an arbitrary for fast-check using jsc2fc
const fcArbitrary = jsc2fc(jscArbitrary);

More details on the package itself!

Test runners

Although not designed for any particular test runners, some users prefer to have complete integration of fast-check within their preferred test runner. To meet these needs, we have compiled a list of packages that serve as the bridge between your favorite test runner and fast-check.

@fast-check/ava

npm version monthly downloads last commit license official package

Bring support for property-based testing into ava with @fast-check/ava.

import { testProp, fc } from '@fast-check/ava';

testProp('should detect the substring', [fc.string(), fc.string(), fc.string()], (t, a, b, c) => {
t.true((a + b + c).includes(b));
});

More details on the package itself!

@fast-check/jest

npm version monthly downloads last commit license official package

Bring support for property-based testing into jest.

In addition to offering enhanced versions of test and it functions, this package seamlessly synchronizes the timeouts of fast-check with those of jest. You no longer need to worry about setting separate timeouts for fast-check when you have already defined one in jest. This package handles the integration effortlessly, ensuring everything gets wired out-of-the-box.

import { test, fc } from '@fast-check/jest';

test.prop([fc.string(), fc.string(), fc.string()])('should detect the substring', (a, b, c) => {
return (a + b + c).includes(b);
});

test.prop({ a: fc.string(), b: fc.string(), c: fc.string() })('should detect the substring', ({ a, b, c }) => {
return (a + b + c).includes(b);
});

More details on the package itself!

@fast-check/vitest

npm version monthly downloads last commit license official package

Bring support for property-based testing into vitest.

import { test, fc } from '@fast-check/vitest';

test.prop([fc.string(), fc.string(), fc.string()])('should detect the substring', (a, b, c) => {
return (a + b + c).includes(b);
});

test.prop({ a: fc.string(), b: fc.string(), c: fc.string() })('should detect the substring', ({ a, b, c }) => {
return (a + b + c).includes(b);
});

More details on the package itself!

Superpowers

Although fast-check already includes an extensive set of capabilities, some features have been kept aside and have not been included within the core package. These additional packages offer some extra capabilities, such as more powerful checks or new runners.

@fast-check/poisoning

npm version monthly downloads last commit license official package

Prototype poisoning is a commonly exploited vulnerability that can lead to various security weaknesses. Historical vulnerabilities in the ecosystem have been linked to prototype poisoning but detecting and addressing them is not always straightforward. The @fast-check/poisoning package has been specifically designed to address this need.

By utilizing this package in conjunction with fast-check, you can effectively safeguard against inadvertently modifying global prototypes when your code interacts with specially crafted inputs. Using both packages together unlocks their full potential and pushes your testing capabilities a step forward.

import fc from 'fast-check';
import { assertNoPoisoning, restoreGlobals } from '@fast-check/poisoning';

const ignoredRootRegex = /^(__coverage__|console)$/;
function poisoningAfterEach() {
try {
assertNoPoisoning({ ignoredRootRegex });
} catch (err) {
restoreGlobals({ ignoredRootRegex });
throw err;
}
}
fc.configureGlobal({ afterEach: poisoningAfterEach });

test('should detect the substring', () => {
fc.assert(
fc.property(fc.string(), fc.string(), fc.string(), (a, b, c) => {
expect(isSubstring(a + b + c, b)).toBe(true);
}),
);
});

More details on the package itself!

@fast-check/worker

npm version monthly downloads last commit license official package

By default fast-check does not change where the code runs: everything run within the original process. @fast-check/worker package allows you to delegate the execution of predicates to dedicated worker threads. It brings several advantages, including the ability to stop synchronously running predicates.

import { test, expect } from '@jest/globals';
import fc from 'fast-check';
import { isMainThread } from 'node:worker_threads';
import { assert, propertyFor } from '@fast-check/worker';

const property = propertyFor(new URL(import.meta.url)); // or propertyFor(pathToFileURL(__filename)) in commonjs
const isSubstringProperty = property(fc.string(), fc.string(), fc.string(), (a, b, c) => {
expect(isSubstring(a + b + c, b)).toBe(true);
});

if (isMainThread) {
test('should detect the substring', async () => {
await assert(isSubstringProperty, { timeout: 1000 });
});
}
Integration with Jest runner

@fast-check/worker is directly integrating with @fast-check/jest. Checkout the official documentation of @fast-check/jest for more details.

More details on the package itself!

Validators

External libraries leveraging fast-check, its properties and predicates to validate userland extensions.

fp-ts-laws 🥇

npm version monthly downloads last commit license third party package

Make sure your fp-ts constructs are properly configured.
More details on the package itself!

Other stacks

Wanna run fast-check in non-JavaScript environments? The following packages offer some bindings making it possible.

rescript-fast-check ⚠️

npm version monthly downloads last commit license third party package

Run fast-check from ReScript code.

open FastCheck
open Arbitrary
open Property.Sync

describe("properties", () => {
it("should detect the substring", () =>
assert_(
property3(string(), string(), string(), (a, b, c) =>
contains(a ++ b ++ c, b)
),
)
)
})

More details on the package itself!