CLI tool for running TWD (Test with Documentation) tests using Puppeteer in CI/CD environments.
npm install twd-cliOr use directly with npx:
npx twd-cli runRun tests with default configuration:
npx twd-cli runCreate a twd.config.json file in your project root to customize settings:
{
"url": "http://localhost:5173",
"timeout": 10000,
"coverage": true,
"coverageDir": "./coverage",
"nycOutputDir": "./.nyc_output",
"headless": true,
"puppeteerArgs": ["--no-sandbox", "--disable-setuid-sandbox"]
}| Option | Type | Default | Description |
|---|---|---|---|
url |
string | "http://localhost:5173" |
The URL of your development server |
timeout |
number | 10000 |
Timeout in milliseconds for page load |
coverage |
boolean | true |
Enable/disable code coverage collection |
coverageDir |
string | "./coverage" |
Directory to store coverage reports |
nycOutputDir |
string | "./.nyc_output" |
Directory for NYC output |
headless |
boolean | true |
Run browser in headless mode |
puppeteerArgs |
string[] | ["--no-sandbox", "--disable-setuid-sandbox"] |
Additional Puppeteer launch arguments |
- Launches a Puppeteer browser instance
- Navigates to your specified URL
- Waits for your app to be ready
- Executes all TWD tests via
window.__testRunner - Collects and reports test results
- Optionally collects code coverage data
- Exits with appropriate code (0 for success, 1 for failures)
The CLI exits with code 1 if any tests fail, making it perfect for CI/CD pipelines.
Puppeteer 24+ no longer auto-downloads Chrome, so make sure you install the browser on each runner (or restore it from a cache) before launching the tests.
# Example GitHub Actions workflow
- name: Install dependencies
run: npm ci
- name: Cache Puppeteer browsers
uses: actions/cache@v4
with:
path: ~/.cache/puppeteer
key: ${{ runner.os }}-puppeteer-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-puppeteer-
- name: Install Chrome for Puppeteer
run: npx puppeteer browsers install chrome
- name: Run TWD tests
run: npx twd-cli run- Node.js >= 20.19.x
- A running development server with TWD tests