Jest
Jest is a simple-to-configure and powerful JavaScript unit testing framework that is built on top of the popular Jasmine framework. Jasmine has been around for a very long time, and is a mature, fully featured, and widely used testing framework. Jest enhances Jasmine by making it easier to configure, as well as providing a wealth of extra features. Jest tests can also be run concurrently, which significantly speeds up the length of time a test suite will take to run. Jest is available through npm, and will therefore require an npm environment, which can be created as follows:
npm init
Here, we have initialized an npm project and can now install the required Jest packages, as follows:
npm install jest --save-dev
With Jest installed, we can either run it using the command npx jest
, or we can modify our package.json
file to specify that Jest will be used when we run npm test
. Let's update our package.json
file as follows:
{
"name": "src...