Skip to main content
TestDriver integrates seamlessly with popular CI providers, enabling automated end-to-end testing on every push and pull request.

Adding Your API Key

TestDriver requires an API key to authenticate with the TestDriver cloud. Store this securely as a secret in your CI provider.
1

Get Your API Key

Go to console.testdriver.ai/team and copy your team’s API key
2

Add Secret to Your CI Provider

Add TD_API_KEY as a secret environment variable in your CI provider’s settings.
Never commit your API key directly in code. Always use your CI provider’s secrets management.

CI Provider Examples

Adding Secrets

  1. Navigate to your GitHub repository
  2. Go to SettingsSecrets and variablesActions
  3. Click New repository secret
  4. Name: TD_API_KEY, Value: your API key
  5. Click Add secret

Basic Workflow

Create .github/workflows/testdriver.yml:
.github/workflows/testdriver.yml
name: TestDriver Tests

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    
    steps:
      - uses: actions/checkout@v4
      
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'
      
      - run: npm ci
      
      - name: Run TestDriver tests
        env:
          TD_API_KEY: ${{ secrets.TD_API_KEY }}
        run: npx vitest --run

Parallel Execution

Use matrix strategy to run tests in parallel:
.github/workflows/testdriver-parallel.yml
name: TestDriver Tests (Parallel)

on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        shard: [1, 2, 3, 4]
    
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'
      - run: npm ci
      - name: Run tests (shard ${{ matrix.shard }}/4)
        env:
          TD_API_KEY: ${{ secrets.TD_API_KEY }}
        run: npx vitest --run --shard=${{ matrix.shard }}/4

Multi-Platform Testing

.github/workflows/testdriver-multiplatform.yml
name: TestDriver Tests (Multi-Platform)

on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        td-os: [linux, windows]
    
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'
      - run: npm ci
      - name: Run tests on ${{ matrix.td-os }}
        env:
          TD_API_KEY: ${{ secrets.TD_API_KEY }}
          TD_OS: ${{ matrix.td-os }}
        run: npx vitest --run

Reading Platform in Tests

When using multi-platform testing, read the TD_OS environment variable in your test:
tests/cross-platform.test.mjs
import { describe, expect, it } from "vitest";
import { TestDriver } from "testdriverai/lib/vitest/hooks.mjs";

describe("Cross-platform tests", () => {
  it("should work on both Linux and Windows", async (context) => {
    const os = process.env.TD_OS || 'linux';
    
    const testdriver = TestDriver(context, { 
      newSandbox: true, 
      headless: false,
      os: os  // 'linux' or 'windows'
    });
    
    await testdriver.provision.chrome({
      url: 'https://example.com',
    });

    const result = await testdriver.assert("the page loaded successfully");
    expect(result).toBeTruthy();
  });
});

Viewing Results

All test runs are automatically recorded and visible in your TestDriver dashboard at console.testdriver.ai:
  • All test runs with pass/fail status
  • Video replays of each test
  • Error messages and screenshots on failure
  • Git commit and branch information
  • Duration trends over time