How to Add Tests to a Vibe-Coded App: A 6-Step Guide
To add tests to a vibe-coded app, start with the two or three flows that would cost you money if they broke — signup, checkout, the main form — and cover each one with a single end-to-end test that drives the real UI. You do not need unit tests, a coverage target, or a testing framework decision before you start. The fastest path is: list your money paths, write one smoke test per path, run it on every deploy, and only then go deeper. An app built with Cursor, Lovable, Bolt, v0 or Replit usually has zero tests because the generator was never asked for them — not because the code resists testing. Adding the first three tests takes an afternoon and catches the class of bug that embarrasses you in front of users.
Why do vibe-coded apps end up with no tests at all?
AI coding tools optimise for a working screen, not a verified one. When you prompt "build me a booking page", the model produces the page; it does not produce the test that proves the booking actually saves. Unless you explicitly ask for tests, you get features only — and because each screen looks right in the preview, there is no moment where the absence of tests feels like a problem.
The gap shows up later, in a specific way. Vibe-coded apps are built in long chains of re-prompts: you ask for a change, the model rewrites a chunk of code, and the screen you were looking at still works. The screen you weren't looking at is the one that broke. That is regression — exactly what tests exist to catch, and why "I clicked through it and it seemed fine" stops scaling after about the fifth re-prompt.
How do you add tests to a vibe-coded app that has none?
Work outside-in. The common mistake is starting with unit tests on helper functions — the easiest things to test, and the least likely to break your product. In a vibe-coded app the risk is concentrated in the glue: form submits that silently fail, auth redirects that loop, database writes that never land, API keys that work locally and not in production. All of that lives at the end-to-end layer.
Here is the order that gets you protection fastest:
- List your money paths. Write down every flow where a failure costs you a user, a payment, or a client call. For most small apps that is three to five flows, not thirty.
- Write one happy-path test per flow. Load the page, fill the form the way a real user would, submit, and assert that the result appeared — the confirmation message, the new row in the list, the redirect. Asserting on the result, not on a spinner, is what makes the test meaningful.
- Add the obvious unhappy path. One test per flow that submits bad input and asserts a clear error shows. AI-generated forms very often validate on the client and forget the server, so this test earns its keep immediately.
- Wire the tests into your deploy. A test suite that only runs when you remember it is a document, not a safety net. Run it on every push, before the deploy completes.
- Add a test every time you fix a bug. This is the single highest-leverage habit. The bug you just fixed is, by definition, a bug your app is capable of having; a test pins it shut.
- Only then go narrower. Once the end-to-end layer is covered, unit tests on pricing maths, date handling and permission checks are worth writing — those are the places where a wrong answer looks like a right one.
Which flows should you test first?
If you are not sure which flows qualify, this is a reasonable default ranking for a small app:
| Flow | What breaks silently | Test first? |
|---|---|---|
| Signup / login | Redirect loops, session not persisting, OAuth callback misconfigured in production | Yes — nothing else matters if users can't get in |
| Checkout / payment | Webhook not handled, order created but never marked paid | Yes |
| Primary form (contact, booking, upload) | Submit returns 200 but nothing is written; email never sends | Yes |
| Data list / dashboard | Empty state shown to users who do have data; wrong user's data shown | Second pass |
| Settings, profile edits | Save appears to work, value reverts on reload | Second pass |
| Marketing pages | Broken links, dead CTAs | Cheap to check, low severity |
Note what is missing from the top of that list: styling, responsive layout, animation. Those matter, but they fail visibly. Tests are most valuable where failure is invisible.
Should you ask the AI to write the tests for you?
Yes, with one rule: never let the same prompt write the feature and judge the feature. If you ask a model to "add tests for this page", it will frequently write tests that assert what the code currently does — including the bug. A test generated from the implementation is a screenshot of the implementation, not a specification.
The way to get useful tests out of an AI tool is to describe the behaviour in your own words first, from the user's point of view, and ask it to write a test for that sentence. "When a logged-out visitor submits the contact form with a valid email, they see a confirmation message and a row appears in the submissions table" is a testable specification. "Add tests for ContactForm.tsx" is not.
Then read what comes back. A test that passes because it asserts true, mocks the entire network layer, or waits for a fixed two seconds is worse than no test, because it buys false confidence. We cover the review habits that catch this in how to review AI-generated code.
How do you keep tests from breaking every time you re-prompt?
This is the real objection, and it is a fair one. If your workflow is "re-prompt until it looks right", a brittle test suite will break constantly and you will delete it within a week. Three things make tests survive re-prompting:
- Select by what the user sees, not by how the markup is built. Target visible text, labels and roles — "the button that says Book now" — rather than CSS classes or deep element paths. AI regenerates class names freely; it rarely renames the button.
- Assert on outcomes, not on internals. A test that checks "the confirmation text appeared" survives a rewrite of the component. A test that checks which function was called does not.
- Keep the suite small on purpose. Five tests you trust and maintain beat fifty you ignore. Every test you add is a thing that can break for the wrong reason.
If your selectors still break every other deploy, that is the problem self-healing tests exist to solve — AutoSim re-anchors a test to the element a human would have clicked instead of failing the run, so a renamed class doesn't read as a product bug.
What if you can't write test code at all?
Plenty of people shipping vibe-coded apps are not going to open a test file, and that is a legitimate position. You still have two options that are strictly better than nothing.
The first is a written manual pass: a short, fixed list of steps you run before every deploy, in the same order, on the deployed URL rather than localhost. Slow and boring, but repeatable — which is the property that matters. Our vibe coding QA checklist is a ready-made version.
The second is to let AI personas do the clicking. Sims runs your flows as simulated users against the live site — filling forms, following links, trying paths you didn't think to try — and reports what broke, with steps to reproduce. It covers the same ground as a smoke suite without you writing one. And when a user does hit something, Snap turns their right-click into a bug report that already carries the console errors, network calls and environment details.
What does "enough tests" look like for a small app?
For a solo founder or a small agency build, a defensible bar is: every money path has a happy-path test, every bug you have ever fixed has a test, and the suite runs on every deploy in a few minutes. That is maybe ten to twenty tests. It will not catch everything — it will catch the regressions that come from re-prompting, which is the failure mode that actually affects you.
Chasing a coverage percentage is the wrong goal. Coverage measures how much code your tests execute, not how much risk they remove — and in an AI-generated codebase full of boilerplate, a high number is easy to reach and tells you almost nothing. For the broader picture, see testing AI-generated code or our complete guide to AI QA.
Start with one test today
Pick the flow that would be most embarrassing to break. Write one test that proves it works. Run it on your next deploy. That single test puts you ahead of most vibe-coded apps in production, and it makes the second one easier to write.
If you would rather have the clicking done for you, try Klavity free — point it at your app and get a list of what's broken before your users find it.
Key takeaways
- List your money paths and write one end-to-end test for each before anything else
- Assert on the result the user sees, not on spinners or internal function calls
- Add a regression test every time you fix a bug — that habit compounds fastest
- Select elements by visible text and roles so tests survive re-prompting
FAQ
How many tests does a vibe-coded app actually need?
For a small app, a defensible bar is one happy-path test per money path, one test per bug you have already fixed, and a suite that runs on every deploy in a few minutes. That is usually ten to twenty tests. Chasing a coverage percentage is the wrong goal, because coverage measures how much code runs during tests, not how much risk they remove.
Should I write unit tests or end-to-end tests first?
End-to-end tests first. In a vibe-coded app, risk is concentrated in the glue between pieces: form submits that silently fail, auth redirects that loop, database writes that never land. Unit tests on helper functions are easier to write but least likely to catch the failures that reach users.
Can I ask Cursor or Claude to write the tests for me?
Yes, but never let the same prompt write the feature and judge it. A model asked to add tests for existing code often asserts what the code currently does, bug included. Describe the expected behaviour in your own words from the user's point of view, ask for a test of that sentence, then read what comes back and reject tests that mock away the network or wait on fixed timers.
My tests break every time I re-prompt. What am I doing wrong?
Usually the tests target markup rather than behaviour. Select elements by visible text, labels and roles instead of CSS classes or element paths, and assert on outcomes the user can see rather than on internal function calls. AI regenerates class names freely but rarely renames a button.
What if I cannot write test code at all?
Two options beat nothing: a fixed written checklist you run against the deployed URL before every release, or AI persona testing that clicks the flows for you and reports what broke with reproduction steps.
Catch bugs the moment a human sees them
Klavity: right-click bug reports, AI personas that review your product, and self-healing tests.
Get started free