Test Tools
- Test Runner: Executes tests and provide validation library
Jest
- Test Utilities: “Simulates” the React App (mounts components, allows you to dig into the DOM):
Enzyme
What to test
- Don’t test complex connections
Don’t test the library
Do test isolated units
- Do test your conditional outputs
Start test
1 | npm install --save enzyme |
1 | // NavigationItems.test.js |
Each test runs independently.
Run test npm run test
Test container components
In container component, export the name of component.
1 | // Component.js |
1 | // Component.test.js |