Skip to main content
CLI Guide

Command Line Interface

Record, run, and manage E2E tests from your terminal with the TestForge CLI.

v2.4.1
125k+ installs

Installation

๐Ÿ“ฆnpm
npm install -g @testforge/cli
๐Ÿงถyarn
yarn global add @testforge/cli
โšกpnpm
pnpm add -g @testforge/cli
๐ŸบHomebrew
brew install testforge

Commands

testforge init
Initialize TestForge in your project

Flags

--template <name>Use a starter template
--forceOverwrite existing configuration

Example

testforge init --template nextjs
testforge record
Start a new recording session

Flags

--url <url>Target URL to record
--browser <browser>Browser to use (chromium, firefox, webkit)
--headlessRun in headless mode
--output <path>Output file path

Example

testforge record --url http://localhost:3000 --browser chromium
testforge run
Execute tests

Flags

--filter <pattern>Run tests matching pattern
--parallel <n>Number of parallel workers
--retry <n>Retry failed tests n times
--reporter <type>Output format (json, html, junit)
--ciCI mode with non-interactive output

Example

testforge run --filter "auth/*" --parallel 4 --retry 2
testforge watch
Run tests on file changes

Flags

--include <glob>Files to watch
--exclude <glob>Files to ignore

Example

testforge watch --include "tests/**/*.ts"
testforge report
Generate test reports

Flags

--format <type>Report format (html, json, markdown)
--output <path>Output directory
--openOpen report in browser

Example

testforge report --format html --open
testforge config
Manage configuration

Flags

get <key>Get a config value
set <key> <value>Set a config value
listShow all configuration

Example

testforge config set browser firefox
testforge update
Update TestForge CLI

Flags

--checkCheck for updates without installing
--betaInclude beta versions

Example

testforge update

Configuration File

Create a testforge.config.js file in your project root to customize the CLI behavior.

Supported formats
testforge.config.js
testforge.config.ts
testforge.config.mjs
.testforgerc
Environment Variables

Override config with environment variables prefixed with TESTFORGE_

TESTFORGE_BROWSER=firefox testforge run
testforge.config.js
// testforge.config.js
export default {
  // Base URL for tests
  baseUrl: 'http://localhost:3000',
  
  // Browser configuration
  browser: {
    name: 'chromium',
    headless: true,
    viewport: { width: 1280, height: 720 }
  },
  
  // Test settings
  tests: {
    directory: './tests',
    timeout: 30000,
    retries: 2
  },
  
  // Screenshot settings
  screenshots: {
    onFailure: true,
    fullPage: false,
    directory: './screenshots'
  },
  
  // CI/CD settings
  ci: {
    reporter: 'junit',
    outputFile: './reports/results.xml'
  },
  
  // Environment variables
  env: {
    TEST_USER: 'test@example.com'
  }
}

Ready to get started?

Install the CLI and record your first test in minutes.