In short
Start by writing end-to-end tests for the journeys that make or cost you money: sign-up, login, the core action and payment. Then test access rules using two accounts and no account. Use AI to write tests, but verify that each can fail. Run them automatically before each release. Don't chase coverage percentages: a handful of reliable tests protects you far more than hundreds of shallow ones.
Start with what would hurt
When you didn't write the code, you can't test everything, and you don't need to. Ask: what would cost us money, data or trust if it broke tonight? Make a list, usually including:
- Signing up and logging in
- Password reset
- The main thing people use your product for
- Payment and access to what they paid for
- One user being unable to see another's data
- Any email or notification that people depend on
Those are your first tests. Our guide to what to test before launch goes further.
Why end-to-end tests come first
There are several kinds of test. See unit, integration or end-to-end tests?. Normally, teams write mostly small unit tests. For an inherited, AI-generated app, start at the other end.
End-to-end tests drive a real browser, the way a user does. They don't care how the code is organised, which is ideal if the code is messy, or if you plan to refactor it. They pin down behaviour from the outside.
Here's an example, using Playwright:
import { test, expect } from "@playwright/test";
test("a new user can sign up and create a project", async ({ page }) => {
await page.goto("/signup");
await page.getByLabel("Email").fill("test+" + Date.now() + "@example.com");
await page.getByLabel("Password").fill("a-long-test-password");
await page.getByRole("button", { name: "Create account" }).click();
await page.getByRole("button", { name: "New project" }).click();
await page.getByLabel("Name").fill("My first project");
await page.getByRole("button", { name: "Save" }).click();
await expect(page.getByText("My first project")).toBeVisible();
});
Note how this test finds elements by what users see. That makes it more resistant to code changes, and it pushes you towards an accessible interface as well. Run tests against a test database and test accounts, and never real customer data. Use your payment provider's test mode.
Test access rules directly
Your interface may hide things that the API happily returns. So write tests that call the API directly:
- Signed out: does a private endpoint refuse?
- As user A: can you read or change user B's data?
- As a regular user: can you reach admin actions?
These are often more important than anything else on the list. Our guides on checking Supabase security in a Lovable app and the security checklist show how. Make them automatic, because new AI-generated features may bring back old holes.
| Test | Must |
|---|---|
| Signed out, call a private endpoint | Refuse |
| As user A, read user B's data | Refuse |
| As user A, change user B's data | Refuse |
| As a regular user, reach an admin action | Refuse |
Using AI to write tests
AI tools are good at writing tests, and they'll save you a lot of time. But there's a trap: tests written by the same tool that wrote the code can share its misunderstanding, or may simply confirm what the code does, whether it's right or not.
expect(page).toBeTruthy()
await expect(page.getByText(
'Order confirmed')).toBeVisible()
To avoid this:
- Describe behaviour, not implementation. “A user whose subscription has lapsed can't export data” is better than “write tests for export.ts”.
- Check that each test can fail. Break the feature on purpose, and make sure the test goes red. A test that can't fail is worse than none, because it gives false comfort.
- Watch for weakened tests. When a test fails, an agent may change the test to make it pass. Read test changes carefully, and tell it not to do that. See how to do a code review.
- Include awkward cases. Empty input, huge input, double clicks, expired sessions, slow networks, a failed payment.
- Add a test for each bug you find. Reproduce it first, then fix it. This is what stops bugs from coming back.
Other tests worth having
Payments. Test successful and failed payments, cancellations and webhooks, including repeated webhooks. See how to handle failed payments.
Email. Use a tool that captures test emails, so that you can check they send.
Mobile. Run key flows at phone sizes, and also try on a real device.
Accessibility. Automated checks catch some issues. See how to test accessibility without a specialist.
Performance with real data. A page that works with ten rows might fail with ten thousand. See can a vibe-coded app scale?
AI features. They're not deterministic, so test against a set of examples rather than exact output. See how to evaluate an LLM feature.
Make it automatic
A test that nobody runs isn't protecting you. Set up your pipeline so that:
- Tests run on each pull request or push
- Failing tests stop the deploy
- Results are visible to the team
See how to set up a CI/CD pipeline for a small team. Most platforms let you do this with little effort, and it's a great task to hand to a coding agent, as long as you check the result.
Keep the suite fast. If it takes half an hour, then people will stop running it. Tests that fail at random will also destroy trust, so fix or remove them quickly.
A simple pre-release routine
Before each release, even with automated tests:
- Automated tests pass
- Sign up and log in with a fresh account
- Do the main task on a phone
- Check error tracking for anything new
- Confirm that you can roll back
After release, watch your errors for an hour or two. See how to monitor a production app and how to set up error tracking. Real users will find things that tests don't.
What not to do
- Don't chase coverage percentages. You can have 90% coverage and no real protection.
- Don't test only the happy path.
- Don't rely on the AI saying “all tests pass”. Check for yourself.
- Don't use production data or live payment keys in tests.
- Don't try to do it all at once. Five good tests today beat a perfect plan you never carry out.
Good tests make everything else easier, including fixing and refactoring your app, and getting better results from your agents. See what harness engineering is.
If you'd like help building a safety net around your app, book a call.
Common questions
What should I test first in a vibe-coded app?
Start with the journeys that make or cost you money: sign-up, login, the core action and payment. Then test access rules, using two accounts and no account. End-to-end tests are a good fit, because they don't depend on how the code is organised.
Can AI write my tests?
Yes, and it can save a lot of time. But check that each test can fail, by breaking the feature on purpose. Watch for agents weakening tests to make them pass, and describe the behaviour you want, rather than asking it to test the code.
How many tests does my app need?
Fewer than you'd think, to begin with. A handful of reliable end-to-end tests covering your critical journeys gives you most of the protection. Add a test whenever you fix a bug, and build gradually. Coverage percentages don't measure much.
Do I need to understand the code to test it?
Not for end-to-end tests. They exercise the app like a user would, so you can describe what should happen, even if you've never read the code. Understanding helps when something fails, and an AI tool can help you investigate.