This project uses Node.js's built-in node:test module for writing and running unit tests, eliminating the need for external libraries like Jest. The test files are organized under the /test directory and executed using the node --test command.
- Tests small pieces of code
- Runs in isolation (individual tests don't depend on each other)
1️⃣ Arrange - Set up test data and conditions
2️⃣ Act - Execute the code being tested
3️⃣ Assert - Verify the results are as expected
- Suits are for grouping related tests
describe
is an alias for Suits
Simulates behavior of dependencies during testing. For example, if function A calls function B internally, we can mock function B.
For more detailed examples, check out order.test.js
Stubs provide ready-made data, similar to mocks, but without tracking call count and other behaviors that mocks provide.
Especially useful for frontend testing when API responses return large JSON objects. Instead of manually asserting each key-pair, snapshots automatically compare the entire structure.
To update snapshots, run:
node --test --test-update-snapshots
Tests how different parts of the application work together.
Every API endpoint is tested using libraries like Jest.
Supertest is excellent for this type of testing.
Tests the entire application flow as a user would experience it:
- Open browser
- Fill in forms
- Check all interactions
Tools: Cypress, Playwright, Puppeteer
- E2E Testing: 10%
- Integration Testing: 20%
- Unit Testing: 70%
⚡ Performance Tip: Make sure tests run as fast as possible. Slow tests increase release time and can increase costs when running in CI/CD pipelines on services like EC2.
Reverses the typical development process:
- Write tests for edge cases first
- Implement the functionality to pass those tests
- Unit Testing
- Integration Testing
- System Testing
- User Acceptance Testing (UAT)
- Smoke Testing
- Sanity Testing
- Regression Testing
- Interface Testing
- Performance Testing
- Load Testing
- Stress Testing
- Spike Testing
- Endurance Testing
- Security Testing
- Usability Testing
- Compatibility Testing
- Reliability Testing
- Scalability Testing
- Accessibility Testing
- Regression Testing
- Maintenance Testing
- Alpha Testing
- Beta Testing
- Ad-hoc Testing
- Exploratory Testing
- Black Box Testing
- White Box Testing
- Grey Box Testing
- Static Testing
- Dynamic Testing