Skip to content

React21S/Product-Unit-testing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Products API testing

1. Create a project folder

2. Create package.json (with npm init or manually)

> npm init -y

3. Install jest as devDependency

> npm install jest --save-dev

This modifies the package.json file by adding devDependencies to it

 "devDependencies": {
    "jest": "^27.5.1"
  }

4. Modify the test-script in package.json change the script from

 "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
to

 "scripts": {
    "test": "jest"
  },

5. Create test folder named

(underscore underscore tests underscore underscore ) __tests__

6. Write tests

7. Run tests

> npm test

7B. To run only one test file

  • test all file that have name test in it
> npm test --testFile fileToBETested.test.js

Products API test cases

Checking the Products API here

API cases for Products storage testing

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


Test result

Testresult


Important link

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published