Testing at Google follows the testing pyramid: many unit tests, fewer integration tests, and minimal E2E tests.
The Testing Pyramid
Unit Tests with React Testing Library
Testing Hooks
Integration Tests
What NOT to Test
- Implementation details (state values, internal methods)
- Third-party library internals
- CSS styling (use visual regression tools instead)
- Constants and configuration
Testing Best Practices
- Test behavior, not implementation
- Use
screen.getByRoleovergetByTestId - Prefer
userEventoverfireEvent(closer to real user behavior) - One assertion per behavior, not per test
- Use MSW for API mocking — it works at the network level