Skip to content

testdriverai/cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TestDriver.ai

Automate and scale QA with computer-use agents.

Docs | Website | GitHub Action | Join our Discord

Install via NPM

Follow the instructions on our docs for more..

v7 SDK - Progressive Disclosure

TestDriver v7 introduces three levels of API to match your experience level:

🟢 Beginner: Presets (Zero Config)

import { test } from 'vitest';
import { chromePreset } from 'testdriverai/presets';

test('login test', async (context) => {
  const { client } = await chromePreset(context, {
    url: 'https://myapp.com'
  });
  
  await client.find('Login button').click();
});

Built-in presets: Chrome, VS Code, Electron, and create your own!

🟡 Intermediate: Hooks (Flexible)

import { test } from 'vitest';
import { useTestDriver, useDashcam } from 'testdriverai/vitest/hooks';

test('my test', async (context) => {
  const client = useTestDriver(context, { os: 'linux' });
  const dashcam = useDashcam(context, client, {
    autoStart: true,
    autoStop: true
  });
  
  await client.find('button').click();
});

Automatic lifecycle management - no more forgetting cleanup!

🔴 Advanced: Core Classes (Full Control)

import { test } from 'vitest';
import { TestDriver, Dashcam } from 'testdriverai/core';

test('my test', async () => {
  const client = new TestDriver(apiKey, { os: 'linux' });
  const dashcam = new Dashcam(client);
  
  await client.auth();
  await client.connect();
  await dashcam.start();
  
  await client.find('button').click();
  
  await dashcam.stop();
  await client.disconnect();
});

Full manual control for advanced scenarios.

📖 Learn more: MIGRATION.md | PRESETS.md | HOOKS.md

About

TestDriver isn't like any test framework you've used before. TestDriver is an OS Agent for QA. TestDriver uses AI vision along with mouse and keyboard emulation to control the entire desktop. It's more like a QA employee than a test framework. This kind of black-box testing has some major advantages:

  • Easier set up: No need to add test IDs or craft complex selectors
  • Less Maintenance: Tests don't break when code changes
  • More Power: TestDriver can test any application and control any OS setting

Demo (Playing Balatro Desktop)

balatro.mp4

Examples

  • Test any user flow on any website in any browser
  • Clone, build, and test any desktop app
  • Render multiple browser windows and popups like 3rd party auth
  • Test <canvas>, <iframe>, and <video> tags with ease
  • Use file selectors to upload files to the browser
  • Test chrome extensions
  • Test integrations between applications
  • Integrates into CI/CD via GitHub Actions ($)

Check out the docs.

Workflow

  1. Tell TestDriver what to do in natural language on your local machine using npm i testdriverai -g
  2. TestDriver looks at the screen and uses mouse and keyboard emulation to accomplish the goal
  3. Run TestDriver tests on our test infrastructure

Quickstart

Initialize TestDriver

In your project directory:

npx testdriverai@latest init

Teach TestDriver a test

Let's show TestDriver what we want to test. Run the following command:

npx testdriverai@latest .testdriver/test.yaml

Reset the test state

TestDriver best practice is to start instructing TestDriver with your app in it's initial state. For browsers, this means creating a new tab with the website you want to test.

If you have multiple monitors, make sure you do this on your primary display.

Instruct TestDriver

Now, just tell TestDriver what you want it to do. For now, stick with single commands like "click sign up" and "scroll down."

Later, try to perform higher level objectives like "complete the onboarding."

> Click on sign up
TestDriver Generates a Test
TestDriver will look at your screen and generate a test script. TestDriver can see the screen, control the mouse, keyboard, and more!
TestDriver can only see your primary display!
To navigate to testdriver.ai, we need to focus on the
Google Chrome application, click on the search bar, type
the URL, and then press Enter.

Here are the steps:

1. Focus on the Google Chrome application.
2. Click on the search bar.
3. Type "testdriver.ai".
4. Press Enter.

Let's start with focusing on the Google Chrome application
and clicking on the search bar.

commands:
  - command: focus-application
    name: Google Chrome
  - command: hover-text
    text: Search Google or type a URL
    description: main google search
    action: click

After this, we will type the URL and press Enter.

TestDriver executes the test script

TestDriver will execute the commands found in the yml codeblocks of the response.

See the yml TestDriver generated? That's our own schema. You can learn more about it in the reference.

Take your hands off the mouse and keyboard while TestDriver executes! TestDriver is not a fan of backseat drivers.

Keep going!

Feel free to ask TestDriver to perform some more tasks. Every time you prompt TestDriver it will look at your screen and generate more test step to complete your goal.

> navigate to airbnb.com
> search for destinations in austin tx
> click check in
> select august 8

If something didn't work, you can use /undo to remove all of the test steps added since the last prompt.

Test the test locally

Now it's time to make sure the test plan works before we deploy it. Use testdriver run to run the test file you just created with /save .

npx testdriverai@latest run testdriver/test.yaml

Make sure to reset the test state!

Deploy

Now it's time to deploy your test using our GitHub action! testdriver init already did the work for you and will start triggering tests once you commit the new files to your repository.

git add .
git commit -am "Add TestDriver tests"
gh pr create --web

Your test will run on every commit and the results will be posted as a Dashcam.io video within your GitHub summary! Learn more about deploying on CI here.

Using as a Module

TestDriver can also be used programmatically as a Node.js module. This is useful when you want to integrate TestDriver into your own applications or customize the test file paths.

Custom Test File Paths

By default, TestDriver looks for test files at testdriver/testdriver.yaml relative to the current working directory. You can customize this:

const TestDriverAgent = require("testdriverai");

// Option 1: Set default via environment variable
const agent1 = new TestDriverAgent({
  TD_DEFAULT_TEST_FILE: "my-tests/integration.yaml",
});

// Option 2: Explicitly specify test file
const agent2 = new TestDriverAgent(
  {},
  {
    args: ["path/to/specific/test.yaml"],
  },
);

// Option 3: Custom working directory + relative path
const agent3 = new TestDriverAgent(
  { TD_DEFAULT_TEST_FILE: "tests/smoke.yaml" },
  { options: { workingDir: "/path/to/your/project" } },
);

// Run the test
await agent1.run();

Environment Variables

You can also set the default test file path using environment variables:

export TD_DEFAULT_TEST_FILE="custom/path/test.yaml"
node your-script.js

MCP Server for AI Agents

TestDriver includes a Model Context Protocol (MCP) server that enables AI agents to interactively create Vitest test files.

How It Works

  1. AI agent connects to a persistent TestDriver sandbox
  2. User describes what they want to test
  3. AI explores the application using TestDriver commands
  4. AI generates Vitest test code from successful interactions

Quick Start

cd mcp-server
npm install && npm run build
npm run deploy  # Install to ~/.mcp/testdriver

Configuration

Add to your MCP client configuration:

{
  "servers": {
    "testdriverai": {
      "type": "stdio",
      "command": "node",
      "args": ["/path/to/cli/mcp-server/dist/index.js"]
    }
  }
}

Example Workflow

User: "Create a test that logs into the app"

AI: [Connects to sandbox with user's API key]
AI: [Takes screenshot to see login page]
AI: [Finds username field: await testdriver_find({ description: "username field" })]
AI: [Clicks and types: await testdriver_type({ text: "test_user" })]
AI: [Finds password field, enters password]
AI: [Clicks login button]
AI: [Asserts login succeeded]
AI: [Generates Vitest test file from these steps]
AI: [Saves test/login.test.mjs]

Key Features

  • Persistent sandbox - Connection stays alive throughout test creation
  • Live debugger URL - User can watch the AI test in real-time
  • Full SDK access - All v7 SDK methods available
  • Code generation - AI translates interactions into proper Vitest code

See mcp-server/TEST_CREATION_GUIDE.md for the complete guide.

About

Next generation autonomous AI agent for end-to-end testing of web & desktop

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 12