CLI Reference¶
Complete reference for rjest command-line options.
Basic Usage¶
Test Selection¶
File Patterns¶
# Run all tests
jest
# Run specific file
jest src/utils.test.ts
# Run multiple files
jest src/utils.test.ts src/api.test.ts
# Run with glob pattern
jest src/**/*.test.ts
Test Name Filtering¶
# Filter by test name
jest --testNamePattern="adds two numbers"
jest -t "adds two numbers"
# Regex patterns
jest -t "add|subtract"
jest -t "should.*error"
Output Options¶
--json¶
Output results in JSON format:
JSON structure:
{
"success": true,
"num_passed_suites": 2,
"num_failed_suites": 0,
"num_passed_tests": 19,
"num_failed_tests": 0,
"duration_ms": 150,
"test_results": [...]
}
--verbose¶
Show individual test names:
--outputFile¶
Save JSON output to file:
Snapshot Options¶
--updateSnapshot, -u¶
Update snapshots instead of comparing:
Watch Mode¶
--watch¶
Re-run tests when files change:
--watchAll¶
Run all tests when any file changes:
Daemon Management¶
--daemon-status¶
Check if the daemon is running:
Output:
--daemon-stop¶
Stop the background daemon:
Free Memory
Run --daemon-stop when you're done testing to free up the ~200MB
used by the daemon and workers.
Configuration¶
--config, -c¶
Specify a custom config file:
--rootDir¶
Set the root directory:
Other Options¶
--version¶
Show version:
--help¶
Show help:
--bail¶
Stop on first failure:
--maxWorkers¶
Set the number of worker processes:
Environment Variables¶
RUST_LOG¶
Enable debug logging:
NO_COLOR¶
Disable colored output:
Exit Codes¶
| Code | Meaning |
|---|---|
| 0 | All tests passed |
| 1 | Some tests failed |
| 2 | Configuration or runtime error |
Examples¶
CI/CD Pipeline¶
# Run tests with JSON output for parsing
jest --json --outputFile=test-results.json
# Fail fast in CI
jest --bail
Development Workflow¶
# Start daemon and run tests
jest
# Make changes, run again (fast!)
jest
# Run specific test while debugging
jest -t "handles edge case" --verbose
# When done, stop daemon
jest --daemon-stop