Skip to main content

Basic Setup

Setup your environment

Setup the project

In this tutorial, you'll need to have Node.js installed.

We will start from an already bootstrapped project to focus on our target: writing our first test.

Setup

You may want to refer to our Getting Started section to setup fast-check in an existing project or without tutorial related code.

npx degit dubzzz/fast-check/website/templates/fast-check-tutorial fast-check-tutorial
cd fast-check-tutorial
npm i

Project structure

Our tutorial project is rather small, it contains the following files:

  • package.json — the dependencies, scripts… used by the project
  • sort.mjs — the code we want to test
  • sort.test.mjs — our test file

This project is relying on Vitest to run the tests.

Test runners

Whether you prefer using Jest, Vitest, Ava or any other, choice is yours! fast-check is designed to be independent of the test runner you use, so you can choose the runner that works best for your project.

Run the tests

You can run the tests written in the test file with:

npm test

We are now ready to start!