Home
Relevant source files
The following files were used as context for generating this wiki page:- website/src/pages/index.js
- website/docusaurus.config.ts
- website/src/components/HomepageFeatures/index.js
- website/src/components/HomepageQuotes/index.js
- packages/fast-check/package.json
- website/blog/2023-05-16-fast-check-loves-docusaurus/index.md
- website/blog/2023-09-04-dual-packages-or-supporting-both-cjs-and-esm/index.md
- packages/fast-check/test/e2e/documentation/Docs.md.spec.ts
- website/blog/2024-03-04-whats-new-in-fast-check-3-16-0/index.md
fast-check is a Property-Based Testing framework for JavaScript and TypeScript designed to work with test runners like Jest, Mocha, and Vitest. Its goal is to make property-based testing accessible to everyone, helping developers find bugs ranging from simple edge cases to complex issues like race conditions and prototype poisoning. The project's official home is its documentation website, fast-check.dev, which has evolved from simple markdown files into a comprehensive site powered by Docusaurus.
This evolution was driven by the need to provide a better user experience with features like easy browsing, searchability, and interactive playgrounds. The website serves as the central hub for documentation, tutorials, API references, and community engagement, reflecting the project's commitment to quality and maintainability.
Sources: packages/fast-check/package.json:3, website/docusaurus.config.ts:8-9, website/blog/2023-05-16-fast-check-loves-docusaurus/index.md:10-101
Website Architecture
The official fast-check website is built using Docusaurus, a modern static site generator. The main configuration is located in website/docusaurus.config.ts, which defines the site's metadata, navigation structure, theme, and plugins. The homepage itself is a React component defined in website/src/pages/index.js, which composes several smaller components to build the final view.
Sources: website/docusaurus.config.ts, website/src/pages/index.js
The following diagram illustrates the component structure of the homepage:
This diagram shows the modular composition of the main landing page, with each section encapsulated in its own React component.
Sources: website/src/pages/index.js:13-19
Navigation
The website's main navigation and footer are configured to guide users to key resources.
| Navigation Item | Link |
|---|---|
| Documentation | /docs/introduction/ |
| Quick Start | /docs/tutorials/quick-start/ |
| All Tutorials | /docs/tutorials/ |
| Support us | /docs/support-us/ |
| Blog | /blog |
| API | https://fast-check.dev/api-reference/index.html |
| GitHub | `https://github.com/dubzzz/fast-check%60 |
Sources: website/docusaurus.config.ts:60-78
Key Features
The homepage highlights several core strengths of the fast-check library.
| Feature | Description |
|---|---|
| Testing made easy | Finding bugs has never been so easy! From classical edge cases to very complex combinations of inputs, fast-check is able to detect any class of bug. |
| Test runner agnostic | fast-check can be used within any test runner without any specific integration needed. It works well with Jest, Mocha, Vitest, and others. |
| Next level testing | Let fuzzing and generative testing help you into uncovering the most challenging bugs: race conditions, prototype poisoning, zero-days… |
Sources: website/src/components/HomepageFeatures/index.js:8-36
A typical fast-check property-based test looks like this:
test('validates substring presence in concatenated string', () => {
fc.assert(
fc.property(fc.string(), fc.string(), fc.string(), (a, b, c) => {
expect(isSubstring(`${a}${b}${c}`, b)).toBe(true);
})
);
});
Sources: website/src/components/HomepageFeatures/index.js:50-58
Packaging and Documentation
The project places a strong emphasis on robust packaging and high-quality, reliable documentation.
Dual Module Support (CJS/ESM)
To ensure broad compatibility, fast-check is published as a dual package, supporting both CommonJS (require) and ES Modules (import). This is achieved by setting the main package type to commonjs and including a nested package.json with type: "module" in the ESM output directory.
The following diagram shows the directory structure used to enable dual module support:
This diagram illustrates the directory and package.json structure for dual CJS/ESM support. Note that the root is ESM, and a nested package file specifies the CJS build.
Sources: website/blog/2023-09-04-dual-packages-or-supporting-both-cjs-and-esm/index.md:91-95, packages/fast-check/package.json:4
The exports field in package.json directs build tools and runtimes to the appropriate files based on the import type.
{
"exports": {
"./package.json": "./package.json",
".": {
"require": {
"types@<5.7": "./lib/cjs/types57/fast-check.d.ts",
"types": "./lib/cjs/types/fast-check.d.ts",
"default": "./lib/cjs/fast-check.js"
},
"import": {
"types@<5.7": "./lib/types57/fast-check.d.ts",
"types": "./lib/types/fast-check.d.ts",
"default": "./lib/fast-check.js"
}
}
}
}
Sources: packages/fast-check/package.json:6-22
Documentation Integrity and Performance
The project ensures its documentation is accurate and performant through automated processes.
-
Snippet Validation: Code snippets in the documentation are automatically tested for correctness. An e2e test suite parses all markdown files, executes the JavaScript blocks, and verifies their validity. This prevents outdated or incorrect examples from being published.
Sources: packages/fast-check/test/e2e/documentation/Docs.md.spec.ts:24-35 -
Website Performance: The documentation site is optimized for speed. Key improvements include optimizing image assets, leveraging better caching with Netlify, and removing performance-heavy scripts like Google Analytics, resulting in near-perfect PageSpeed scores.
Sources: website/blog/2024-03-04-whats-new-in-fast-check-3-16-0/index.md:33-54
The diagram below shows the workflow for validating documentation snippets.
This flowchart outlines the automated process that ensures code examples in the documentation are always correct and up-to-date.
Sources: packages/fast-check/test/e2e/documentation/Docs.md.spec.ts:74-188
Community Engagement
The project is actively used and appreciated by the community. The homepage showcases testimonials from developers at companies like Google and Microsoft and maintainers of popular open-source projects like TypeScript and XState.
"Wrote one property based test with @ndubien's fast check and immediately found & fixed 3 bugs. How is generative testing not mainstream yet?"
— Adam Berger
"I added a fast-check unittest to fuzz the parser and in seconds it found the same bug."
— Jake Bailey, Senior Software Engineer at Microsoft (TypeScript)
Sources: website/src/components/HomepageQuotes/index.js:58-71, 91-102