Using the Jest framework
Jest is a modern test framework that was authored by Facebook to fully leverage Node.js for running tests. It should have the power to run all the tests required at Facebook without requiring a diploma in engineering to understand, control, or modify it.
To use Jest, you need to install the jest
package from npm:
$ npm install jest --save-dev
This allows you to use the jest
command-line utility. Ideally, run it with npx
as we did with the other tools:
$ npx jest
Jest can be configured by providing a jest.config.js
file. The easiest way to create this kind of file is by using the jest
tool with the --init
flag. This will guide us through some questions to create a suitable configuration:
$ npx jest --init
The following questions will help Jest to create a suitable configuration for your project
Would you like to use Jest when running "test" script in "package.json"? … yes
Would you like to use Typescript for...