Vibe Coder · Unit 13: Testing and Security · Lesson 5 of 11
Automated tests
Engineers: unit, integration and end-to-end tests written with an agent, and how to make sure they test something real.
Read the short notes and pictures.Do everything inside a blue frame.
Tests that run themselves
Automated tests turn your test plan into code that runs on every change. Agents are good at writing them, and prone to writing ones that assert little. The discipline is to confirm each test fails for the right reason.

What to automate first
The main path, end to end
Sign up, do the one job, see the result.
Access rules
User A cannot read user B’s rows.
Money and maths
Any calculation.
The AI route
With a mocked model client.

Working with an agent
Write the test first
From the "done" sentence.
Watch it fail
Before the code exists or with the code broken.
Implement until it passes
Without editing the test.
Forbid weakening
A rule in CLAUDE.md: never change a test to make it pass.
Automate your main path
Add an end-to-end test for the main path, an integration test for RLS, and unit tests for your calculations. Prove each can fail, and run them in CI.
Done when
Your test plan now runs on every pull request.
Keep these
- Automate the main path, access rules and maths.
- Make every test fail once.
- Run them in CI.