First, create a folder and then create package.json
file using:
cd folder-name
npm init
Then, Install the Jest dependency. For NPM:
npm install --save-dev jest
For Yarn:
yarn add --dev jest
To Run Test:
npm test
Result:
To view built-in code coverage report
, Install Jest globally. Run:
npm install -g jest
Then:
jest --coverage
Result: