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

Authentication

On GitHub Actions, prefer OIDC via the published testdriverai/action — there’s no TD_API_KEY secret to store, copy, or rotate. The action proves the workflow is running inside your org and TestDriver exchanges that proof for your team’s key at run time. See the GitHub Actions tab below. For other CI providers (or self-hosted runners without OIDC), fall back to a stored API key from console.testdriver.ai/team, added as a TD_API_KEY secret in your CI provider’s settings.
Never commit your API key directly in code. Always use OIDC or your CI provider’s secrets management.

CI Provider Examples

Use the published testdriverai/action — it mints the OIDC token, exchanges it for your team’s API key, and exports TD_API_KEY for the steps that follow. No TD_API_KEY secret to store or rotate.
One-time setup: authorize the TestDriver GitHub App for your org so the org → team binding exists. If your org authorized the App before OIDC support shipped, re-authorize once. If the App isn’t authorized, the action fails with a console link (or falls back to the api-key secret if you provide one).
.github/workflows/testdriver.yml
name: TestDriver Tests

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

jobs:
  test:
    runs-on: ubuntu-latest
    permissions:
      id-token: write   # REQUIRED to mint an OIDC token
      contents: read

    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'

      - run: npm ci

      - name: Authenticate to TestDriver
        uses: testdriverai/action@stable   # pin @stable / @canary / @test to your SDK channel
        with:
          api-key: ${{ secrets.TD_API_KEY }}   # optional fallback if OIDC isn't set up

      - name: Run TestDriver tests
        run: npx vitest run

Stored-key fallback

Only if you can’t use OIDC (e.g. self-hosted runners without an OIDC provider). Add the key as a secret and pass it via env:
  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: 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: 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: 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/vitest/hooks";

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, { 
      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();
  });
});

Concurrency limits

Your plan allows a fixed number of sandboxes running at once. When a test asks for a sandbox and you’re already at that limit, the request is queued rather than failed immediately: the SDK waits for a slot to free up, retrying every 10 seconds, then proceeds automatically once one opens. This is what lets a parallel CI matrix (many jobs starting at once) work on a plan with fewer slots than jobs — the extra jobs simply wait their turn instead of erroring. By default the SDK waits up to 60 seconds for a slot before giving up with a concurrency-limit error. Control that ceiling with TD_CONCURRENCY_MAX_WAIT:
ValueBehavior
unsetWait up to 60 seconds (the default).
TD_CONCURRENCY_MAX_WAIT=300Wait up to 300 seconds (5 minutes) before giving up.
TD_CONCURRENCY_MAX_WAIT=0Don’t queue — fail on the first denial.
The value is in seconds (fractional values are allowed and rounded to the nearest millisecond). Any invalid or negative value falls back to the 60-second default. The wait applies per sandbox request, across both the initial allocation and the realtime slot-approval handshake.
# Example: a large parallel matrix that may queue for a while.
# Give each job up to 5 minutes to acquire a slot before failing.
- name: Run TestDriver tests
  env:
    TD_API_KEY: ${{ secrets.TD_API_KEY }}
    TD_CONCURRENCY_MAX_WAIT: "300"
  run: npx vitest run
Raise TD_CONCURRENCY_MAX_WAIT when you run more parallel jobs than your plan has slots and would rather they queue than fail. Set it to 0 when you’d prefer a job to fail fast on a busy account (e.g. a quick smoke test that shouldn’t sit waiting). When jobs routinely give up waiting, that’s the signal to add more slots.

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