> npm init -y
> npm install jest --save-dev
This modifies the package.json file by adding devDependencies to it
"devDependencies": {
"jest": "^27.5.1"
}
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
to
"scripts": {
"test": "jest"
},
(underscore underscore tests underscore underscore )
__tests__
> npm test
- test all file that have name test in it
> npm test --testFile fileToBETested.test.js
Checking the Products API here
Checking for testing Products constructor cases here
Checking for testing Products by getById(id) cases here
Checking for testing Products by getAllIdsByModel cases here
Checking for testing Products by getAllProductTypes cases here
Checking for testing Products by getAllProductsByType(type) cases here
Checking for testing Products by hasAccessories(id) cases here
Checking for testing Products by GetProductAccessories(id) cases here
Checking for testing Products by getPriceWithoutExtras(id) cases here
Checking for testing Products by getTotalPrice(id) cases here
Checking for testing Products by getPriceOfTheExtras(id) cases here
-
Jest installation procedure