12 parts
Write tests that let you change code without fear: unit tests, TDD, mocking, async testing, API integration tests, and CI, with Vitest.
Tests don't prove your code works. They're what lets you change it six months from now without breaking something you can't see happen.
5 min read
Install Vitest, write one real assertion, and see exactly what expect() checks under the hood before you ever run npx vitest for real.
Every clear test follows the same three-part shape. Learn to spot it, write it on purpose, and see why messy tests almost always skip a step.
Write the test before the code that passes it. A live walkthrough of the red-green-refactor loop, building a slugify function from nothing.
The bugs that reach production almost never live in the happy path. Two real tests, from a real code review, show what actually catching them looks like.
Replace the database, the email API, or a slow dependency with something you control. Three techniques, what they're each for, and where they go wrong.
4 min read
A test that passes locally and fails randomly in CI is almost always a missing await. Learn the pattern, fake timers, and why Express 5 changed the game.
Unit tests check one function. Integration tests check the whole request through routing, auth, and validation. Real supertest tests against a real API.
Shared test databases cause the flakiest failures in any suite. See why Linkstash defaults to an in-memory database, and how fixtures set up test data.
100% coverage means every line ran during the suite. It says nothing about whether the right values were checked. A real bug that coverage missed.
Test what a user can see and click, not internal state or class names. Build a live save-link form, then test it with Testing Library like a real user.
A test suite that only runs on your laptop is a suggestion. Wire Vitest into GitHub Actions so every push and pull request runs it automatically.