Skip to main content
Describe a flow in plain language, and the TestDriver agent writes the test for you.
  • The agent runs in your AI coding assistant.
  • It runs the flow in a live sandbox and writes a Vitest test.
  • It finds elements by looking at the screen, so you never write selectors.

Before you begin

Install TestDriver in an AI coding assistant that can edit files in your repository:

Start the agent

Ask for the TestDriver agent by name in your assistantโ€™s chat:
In VS Code, you can also pick testdriver from the agent dropdown in the Copilot chat panel. If your assistant doesnโ€™t support agent files, give it the TestDriver agent instructions directly.

Describe the test

Write the flow as the steps a user takes and what they should see at the end. Explicit steps make a test faster, cheaper, and more reliable than one where the agent works out the flow itself:

Watch and steer the run

The agent sends a screenshot after every action, so you see what it sees.
  • In clients that support MCP Apps, each screenshot appears inline in the chat, with the targeted element highlighted.
  • With the TestDriver extension in VS Code or Cursor, the sandbox also plays live in a panel beside your code.
If the agent gets stuck or takes a wrong turn, tell it what to do next:
You can also ask for more checks at any point:

What the agent does

  1. Starts a session. It provisions a sandbox (Linux by default) and opens your app, for example Chrome at the URL you gave it.
  2. Performs each step. It finds each element from a description, acts on it, and checks the screenshot to confirm the step worked.
  3. Writes code as it goes. After each successful action, it appends the matching SDK code to a test file under tests/. The file always reflects what has actually run.
  4. Runs the test. It runs the file with vitest run and keeps fixing it until it passes.

Review the generated test

The result is an ordinary Vitest file. Read, edit, commit, and run it in CI like any other test:
tests/login.test.mjs
Before you commit, check two things:
  • Each find() description would still pick the right element if the page changed.
  • The assertions cover what you care about.
If the test calls ai(), which works out a step on its own at run time, ask the agent to replace it with explicit find(), click(), and type() steps before you commit. Explicit steps run faster and do the same thing every time.

Tips for better tests

โ€œThe blue Sign In button in the headerโ€ works better than โ€œthe buttonโ€. Include the visible label. Add position or color when several elements look alike. See Locate elements.
If part of your app loads slowly, say so. For example: โ€œwait for the loading spinner to disappear before continuingโ€. The agent then waits instead of acting too early.
Assert after each meaningful action, such as โ€œthe item appears in the cartโ€. When the test fails later, you see where the regression starts.
Donโ€™t describe a long workflow all at once. Have the agent get the first part passing, then describe the next.

Next steps

Run tests

Choose a device, preview mode, and how to run your tests.

Speed up reruns with caching

Reuse what TestDriver found so reruns skip the AI.

Make assertions

Write checks that catch the regressions you care about.

Run in CI/CD

Run generated tests on every pull request.