TestDriver is an AI code reviewer that actually runs your app. It automatically runs every pull request in a real desktop sandbox, finds bugs, and builds regression tests. Tests control browsers and native applications using natural language element descriptions and AI vision, and run as Vitest suites. This skill teaches an agent how to author, run, and debug TestDriver tests.
npx testdriverai init
This scaffolds package.json, example tests, vitest.config.mjs, and a GitHub Actions workflow. The user must set TD_API_KEY in .env (get a key at https://console.testdriver.ai/team).
Tests are Vitest suites using the TestDriver hooks:
import { describe, expect, it } from "vitest";
import { TestDriver } from "testdriverai/vitest/hooks";
describe("Login", () => {
it("signs in successfully", async (context) => {
const testdriver = TestDriver(context);
await testdriver.provision.chrome({ url: "https://example.com/login" });
const email = await testdriver.find("email input field");
await email.click();
await testdriver.type("user@example.com");
const submit = await testdriver.find("Sign In button");
await submit.click();
const result = await testdriver.assert("the dashboard is visible");
expect(result).toBeTruthy();
});
});
vitest run tests/login.test.mjs
Screenshots are captured automatically before and after every command and saved to .testdriver/screenshots/, named with the source line number for easy debugging.
await testdriver.provision.electron({ appPath: "./dist/my-app" });
const menu = await testdriver.find("File menu in the menu bar");
await menu.click();
const done = await testdriver.find("Loading complete indicator", { timeout: 30000 });
await done.click();
testTimeout and hookTimeout to 900000 in vitest.config.mjs
assert() calls for verifiable pass/fail conditionsawait every TestDriver callnpx vitest; run vitest run directlyTD_API_KEY) and network access to provision sandboxes.npx testdriverai init writes project files to the current directory; run it only in a project you intend to modify.TD_API_KEY credential belongs in .env (gitignored by the scaffold). Never commit it.hookTimeout: 900000 in vitest.config.mjs; sandbox teardown and recording uploads take longer than Vitest's default.@webapp-testing - Playwright-based alternative for local web apps with stable DOM selectors