By the end of this lesson you will know why AI agents break features that used to work, what an automatic test is, and what your job is when the AI writes the tests.
You need: nothing installed yet, only an app idea or an app you built with an agent (the first web MVP or the mini CRM is perfect) · Time: 7 minutes
Meet Sharma Coaching Classes in Jaipur. Mr Sharma built a fee tracker with an AI agent. Its rules: the monthly fee is ₹1,500, due on the 10th. After that, a late fee of ₹50 per day, but never more than ₹500.
One evening he asked the agent: "Add a button that sends a WhatsApp reminder to parents." The button worked. But while adding it, the agent "tidied up" the fee code and quietly dropped the ₹500 limit. Two weeks later, a parent who paid 30 days late was asked for ₹3,000 instead of ₹2,000. The parent was angry, and Mr Sharma had no idea when it broke.
This is a regression: something that worked before stops working after a change. Developers everywhere complain about it. In the 2025 Stack Overflow survey, the top frustration with AI tools was code that is "almost right, but not quite".
Why?An agent edits many lines to make one change, and it does not remember which quiet rules those lines were protecting. It is not careless on purpose. It simply cannot see what you never wrote down and never checked.
A test is a tiny program that uses your app and checks one answer. For example: "feed in a ₹1,500 fee paid 30 days late, the answer must be ₹2,000". If the answer is right, the test passes (green). If not, it fails (red) and tells you what it expected and what it got.
In Build your first web MVP you wrote a
TESTING.mdchecklist and clicked through it by hand. That is still useful. An automatic test is the same idea, except the computer does the clicking and checking:- A manual check takes you 20 minutes, so you do it once before launch.
- An automatic test takes a second or two, so you can run it after every change.
A test suite is all your tests together. One command runs the whole suite.
Match them Match each word with its meaning
Tap an item on the left, then its meaning on the right.
Why?Mr Sharma's bug would have been caught the same evening by one test, in about one second. A test is a rule that checks itself every time, so you don't have to remember to.
You will use two kinds, and you need many of one and few of the other:
- Unit tests check one small piece of logic, like "what is the fee for this student today?". No browser, no clicking. They take milliseconds, so you can have dozens. In this course they run with Vitest, a free test tool for JavaScript projects.
- End-to-end tests (often called e2e) open a real browser and click through a whole journey, like "log in, find a student, mark the fee as paid, see the receipt". They are slower, so you keep a few for the journeys that matter most. They run with Playwright, a free tool from Microsoft.
On top sits a quick look by you before launch, which no tool replaces.
Many fast unit tests, a few end-to-end tests, and one quick look by you. Why?If every check were an end-to-end test, your suite would take minutes and you would stop running it. Money rules belong in fast unit tests; only the main journeys need a browser.
You do not need to read or write test code. Split the work like this:
You The AI Write the rules in plain English, with real numbers Turns each rule into test code Decide which journeys matter Installs Vitest and Playwright and writes the tests Read the result: pass or fail, which test, expected vs received Runs the tests and pastes the full output Say no to deleting, skipping or weakening a test Fixes the app code when a test fails Here is what a result looks like. You will see this many times in this course:
You only need two lines: the ✓ or ✗ marks, and the Tests line with how many passed out of how many.
Why?You know the business rules better than any AI: that the late fee stops at ₹500, that siblings get 10% off. The AI is faster at writing code. Tests are where your knowledge and its speed meet.
Do it now Do it now
When a test fails, the quickest way to make it green is not to fix the app. It is to change the test. Agents have been caught doing exactly this: changing the expected number, deleting the failing test, or marking it to be skipped. People have filed public bug reports about it, such as an issue on the Claude Code GitHub repository titled "Claude Code manipulates tests instead of following instructions".
So you will learn three habits in this course:
- Tests are written from your rules, not from whatever the code does today.
- You ask for evidence: the full pasted test output, never "I tested it, it works".
- The number of tests never goes down without your OK, and no test is skipped.
Careful"All tests pass" means nothing if the AI quietly removed the test that was failing. Always look at how many tests ran, not only at the word "passed".
Why?Tests only protect you if nobody bends them. Knowing that the AI might is half of the protection.
- AI agents cause regressions: a change to one feature silently breaks another.
- A test checks one answer automatically; a test suite runs them all with one command.
- Many fast unit tests (Vitest) for rules, a few end-to-end tests (Playwright) for main journeys.
- You write the rules and read the results; the AI writes and runs the test code.
- Next: turn your rules into test cases.
Create a free account to save your progress and open every lesson. Create free account