Testing: Unit Tests, Mocks and Test-Driven Development
Learn Testing: Unit Tests, Mocks and Test-Driven Development (Phase 13 · Security and Testing (Essential for production), JavaScript) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Why and what to test • Automated tests catch regressions and make refactoring safe. The testing pyramid : many fast unit tests, fewer integration tests, a few end-to-end tests. • Popular runners: Vitest (Vite projects), Jest , and the built-in node:test . Each test follows Arrange, Act, Assert . • Test behaviour (inputs and outputs), not implementation details.