Skip to content

Latest commit

 

History

History
33 lines (24 loc) · 1.36 KB

coding-assignment.md

File metadata and controls

33 lines (24 loc) · 1.36 KB

Learn React With Harshi Series

Documenting my learning journey of Namaste React Live Course conducted by Akshay Saini

Coding Assignment: Chapter-13 Time for the test (05/02/2023)

Build a Food Ordering App - Chapter-13 features

1. Setup React Testing Library

  1. Install React Testing library - npm install --save-dev @testing-library/react
  2. Install Jest - npm install -D jest
  3. Configure Jest -> npx jest --init
  4. Typescript -> N
  5. environment -> jsdom (broswer-like)
  6. code coverage -> y
  7. provider for coverage -> babel
  8. automatically clear before test -> y
  9. Creates jest.config.js
  10. scripts -> test : jest
  11. npm install -D jest-environment-jsdom
  12. jest is trying to find test cases in the app under tests folder
  13. npm install --save-dev babel-jest @babel/core @babel/preset-env - why ? because jest does not understand import statement.
  14. to configure babel -> babelrc file or babel.config.js
  15. Add the following code to .babelrc file -> "presets" : [["@babel/preset-env", {"targets": {"node": "current"}}], ["@babel/preset-react", {"runtime" : "automatic"}]]

2. Write Unit Tests for Header Component to test for Logo, Cart 0 items and Online Status

3. Write Integration Test case for search feature on the Homepage

4. Write Integration Test case for Add to Cart flow