Guided Notes

Testing & Debugging Node.js Apps

Unit tests with node:test or Vitest, testing APIs with Supertest, mocking, debugging with the inspector, logging, and common runtime errors.

Why test

Slide 1 / 5

Tests let you change code without fear. A good test suite has: • many fast unit tests for pure logic (pricing, validation), • some integration tests for routes and database code, • a few end-to-end tests for critical flows.

Node has a built-in test runner (node:test with node:assert); Vitest and Jest are popular alternatives with watch mode and rich features.