1. Unit Testing
- Tests individual functions, components, or modules in isolation.
- Focuses on verifying the smallest pieces of code (e.g., a function returns the expected result).
- Usually fast to run since no external dependencies are involved.
- Tools: Vitest, Jest, Mocha.
- Helps catch bugs early during development.
2. Integration Testing
- Tests how multiple units or modules work together.
- Ensures correct communication between components (e.g., frontend calls backend API properly).
- More realistic than unit tests, but still less complex than full system tests.
- Tools: React Testing Library, Supertest, Playwright (for APIs).
- Harder than unit testing since we may need to mock server data.
3. End-to-End (E2E) Testing
- Simulates real user workflows across the entire application.
- Tests from frontend → backend → database (full stack).
- Ensures that critical paths (like login, checkout, form submission) work as expected.
- Usually slower and more expensive to run than unit/integration tests.
- Tools: Cypress, Playwright, Selenium.