Testing your application is a powerful tool in improving the quality of your Hub applications. Good storytelling test descriptions increase the comprehension of your application's codebase, user flow coverage ensures your application is fulfilling its requirements, and all types of tests increase the release confidence.
First concentrate on high level E2E tests and move to more specific test types as you see fit. This approach is outlined in Approach, the testing pyramid from the top!
While E2E tests give you the highest confidence type of tests, we recognize they can be complicated, slower and more brittle than other tests. How Cypress solves UI testing and E2E with Cypress can help you successfully implement E2E tests for your application.
Integration test runs the whole app in a real browser without hitting a real server, which is opposite to E2E testing where app interacts with the real server. Those tests are blazing fast and less exposed to random failures or false negatives. Cypress is perfect for UI Integration tests.
- React Testing Library along with Jest provides APIs for testing React components.
- React Hooks Testing Library provides similar APIs for React hooks.
Unit Tests tend to be the simplest and most granular types of tests. The downside of unit tests lies in their low level focus which can often result in testing external dependencies more so than the Hub application itself.
Jest allows you to write tests with an approachable, familiar and feature-rich API. Jest is well-documented, requires little configuration, and can be extended when needed. With Jest, you can conduct snapshot, parallelization, and async method tests, mock first and thrid-party functions, execute myriad assertion methods, and view code coverage report.
Writing tests when the app is wrapped in
When writing tests for React apps that use
AuthContext , you can mock the context to enable tests to run outside of a host like the Hub shell.