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 testforgeCommands
testforge init
Initialize TestForge in your project
Flags
--template <name>Use a starter template--forceOverwrite existing configurationExample
testforge init --template nextjstestforge 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 pathExample
testforge record --url http://localhost:3000 --browser chromiumtestforge 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 outputExample
testforge run --filter "auth/*" --parallel 4 --retry 2testforge watch
Run tests on file changes
Flags
--include <glob>Files to watch--exclude <glob>Files to ignoreExample
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 browserExample
testforge report --format html --opentestforge config
Manage configuration
Flags
get <key>Get a config valueset <key> <value>Set a config valuelistShow all configurationExample
testforge config set browser firefoxtestforge update
Update TestForge CLI
Flags
--checkCheck for updates without installing--betaInclude beta versionsExample
testforge updateConfiguration 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 runtestforge.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'
}
}