[[MIRROR from GitHub]] Property based testing framework for JavaScript (like QuickCheck) written in TypeScript fast-check.dev
1.4 kB · 48 lines
Markdown
at main


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.

:::info[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.

:::tip[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!