Test Driven Development

Drives development with tests. Use when implementing any logic, fixing any bug, or changing any behavior. Use when you need to prove that code works, when a bug report arrives, or when you're about to modify existing functionality.

The Beyoncé Rule: if you liked it, you should have put a test on it.
Step 1
Write a failing test
✕ FAIL
// RED: createTask doesn't exist yet
it('creates a task with title and default status', async () => {
  const task = await taskService.createTask({ title: 'Buy groceries' });
  expect(task.title).toBe('Buy groceries');
  expect(task.status).toBe('pending');
  expect(task.createdAt).toBeInstanceOf(Date);
});
A test that passes immediately proves nothing.

Related