Unit tests verify small pieces of logic in isolation. Good unit tests are focused, deterministic, readable, and quick to run.
Node.js includes a built-in test runner, which is enough to start testing many small applications without adding another test framework.
Deep dive
What should be tested?
- Normal successful cases.
- Boundary values.
- Invalid input.
- Expected errors.
- Important business rules.
Testing pyramid idea
Keep many fast unit tests, add integration tests for database and service boundaries, and use a smaller number of end-to-end tests for complete user flows.