- Using
create-react-app
, what do we need to set up for testing? - What components are worth to test in your development?
- Can you apply TDD once you already created components?
NOTE: Apply TDD as much as you can.
- Find any sub-routine, extract that logic into a separate file and test it out.
- Run test coverage and save results into a .txt file at ./ - root level. Can you make the total coverage to be above of 60%?
- Meaningful test cases were implemented for components and sub-routines logic.
- All the test cases were successful.
- Test coverage is above 60%.
Answers:
to start testing using create-react-app me need to install our prefered tool like jest or react testing library, in this case I choose jest, we need to install it:
npm install --save-dev jest
after this we create two files like funcionality1.js (where code goes) and functionality1.test.js (where we are going to test our code)
then we edit the package.json like this
{
"scripts": {
"test": "jest"
}
}
finally we run _npm run test or yarn test
these are some of the components worth to test: