or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

cli-interface.mdconfiguration.mdexception-execution.mdindex.mdtest-assertions.mdtest-control.mdtest-creation.md
tile.json

cli-interface.mddocs/

CLI Interface

Command-line interface tools for running tests across different runtime environments.

Capabilities

Binary Executables

Brittle provides runtime-specific binary executables for different JavaScript environments.

// Available binary executables:
// brittle - Default Node.js runtime
// brittle-node - Explicit Node.js runtime  
// brittle-bare - Bare runtime
// brittle-pear - Pear runtime

Usage Examples:

# Run tests with default Node.js runtime
npx brittle test/*.js

# Explicit Node.js runtime
npx brittle-node test/*.js

# Bare runtime
npx brittle-bare test/*.js

# Pear runtime  
npx brittle-pear test/*.js

# Run with specific options
npx brittle --solo --timeout 10000 test/*.js

# Enable coverage with custom directory
npx brittle --coverage --cov-dir ./my-coverage test/*.js

# Generate test runner file
npx brittle --runner ./generated-runner.js test/*.js

# Run with tracing and bail on first failure
npx brittle --trace --bail test/*.js

Command Line Flags

Comprehensive CLI options for controlling test execution behavior.

// CLI Flags:
// --solo, -s             - Engage solo mode
// --bail, -b             - Bail out on first assert failure  
// --coverage, -c         - Turn on coverage
// --cov-dir <dir>        - Configure coverage output directory (default: ./coverage)
// --trace                - Trace all active promises and print them if the test fails
// --timeout, -t <timeout> - Set test timeout in milliseconds (default: 30000)
// --runner, -r <runner>  - Generate test runner file that contains all target tests
// --mine, -m <miners>    - Keep running tests in <miners> processes until they fail
// --unstealth, -u        - Show assertions even if stealth is used

Environment Variable Configuration

Configure default CLI options using the BRITTLE environment variable.

// Environment Variables:
// BRITTLE - Space or comma-separated CLI flags applied to all runs

Usage Examples:

# Set default options via environment variable
export BRITTLE="--solo --timeout 10000"
npx brittle test/*.js  # Runs with solo mode and 10s timeout

# Combine environment and CLI flags
export BRITTLE="--coverage"
npx brittle --bail test/*.js  # Runs with coverage and bail mode

# Multiple options
export BRITTLE="--timeout 30000 --unstealth --trace"
npx brittle test/*.js

# Package.json with environment variable
{
  "scripts": {
    "test": "BRITTLE=\"--coverage --timeout 30000\" brittle test/*.js",
    "test:solo": "BRITTLE=\"--solo --bail\" brittle test/*.js"
  }
}

Solo Mode

Run only specific tests, skipping all others.

# Enable solo mode globally
npx brittle --solo test/*.js
npx brittle -s test/*.js

# Combine with other options
npx brittle --solo --timeout 10000 test/*.js

Usage in Tests:

import { solo, test } from "brittle";

// This test will run
solo("focused test", (t) => {
  t.pass("only this runs when --solo is used");
});

// This test will be skipped
test("regular test", (t) => {
  t.pass("this is skipped in solo mode");
});

Bail Mode

Exit immediately when the first test fails.

# Enable bail mode
npx brittle --bail test/*.js
npx brittle -b test/*.js

# Useful for CI environments
npx brittle --bail --coverage test/*.js

Coverage Reporting

Enable code coverage collection and reporting.

# Enable coverage with default directory
npx brittle --coverage test/*.js
npx brittle -c test/*.js

# Custom coverage directory
npx brittle --coverage --cov-dir ./my-coverage test/*.js

# Coverage with other options
npx brittle -c -b --timeout 30000 test/*.js

Timeout Configuration

Set global timeout for all tests.

# Set 30 second timeout
npx brittle --timeout 30000 test/*.js
npx brittle -t 30000 test/*.js

# Useful for slow CI environments
npx brittle -t 60000 --bail test/*.js

Promise Tracing

Enable promise tracing for debugging deadlocks and unresolved promises.

# Enable promise tracing
npx brittle --trace test/*.js

# Combine with other debugging options
npx brittle --trace --unstealth test/*.js

Test Runner Generation

Generate a test runner file for advanced usage scenarios.

# Generate runner file
npx brittle --runner my-runner.js test/*.js
npx brittle -r my-runner.js test/*.js

Mining Mode

Continuously run tests until they fail, useful for flaky test detection.

# Run tests 100 times or until failure
npx brittle --mine 100 test/*.js
npx brittle -m 100 test/*.js

# Infinite mining (until failure)
npx brittle --mine 0 test/*.js

Stealth Override

Show individual assertions even in stealth mode tests.

# Override stealth mode
npx brittle --unstealth test/*.js
npx brittle -u test/*.js

# Useful for debugging stealth tests
npx brittle -u --trace test/*.js

Runtime-Specific Usage

Node.js Runtime

Standard Node.js environment with full feature support.

# Explicit Node.js runtime
npx brittle-node test/*.js

# With Node.js specific options
npx brittle-node --coverage --trace test/*.js

# Package.json script
{
  "scripts": {
    "test": "brittle-node test/*.js",
    "test:coverage": "brittle-node --coverage test/*.js"
  }
}

Bare Runtime

Minimal JavaScript runtime optimized for performance.

# Bare runtime
npx brittle-bare test/*.js

# Bare with coverage
npx brittle-bare --coverage test/*.js

# Package.json for Bare
{
  "scripts": {
    "test:bare": "brittle-bare test/*.js"
  }
}

Pear Runtime

Pear application runtime environment.

# Pear runtime
npx brittle-pear test/*.js

# Pear with specific options
npx brittle-pear --solo --timeout 15000 test/*.js

File Patterns

Support for various file pattern specifications.

# Single file
npx brittle test/my-test.js

# Multiple files
npx brittle test/test1.js test/test2.js

# Glob patterns
npx brittle "test/**/*.js"
npx brittle "test/*.test.js"

# Mixed patterns
npx brittle test/*.js integration/*.test.js

Environment Integration

CI/CD Integration

# GitHub Actions
npx brittle --bail --coverage --timeout 30000 test/*.js

# GitLab CI
npx brittle -b -c -t 45000 test/*.js

# Jenkins
npx brittle --bail --cov-dir coverage test/*.js

Package.json Scripts

{
  "scripts": {
    "test": "brittle test/*.js",
    "test:watch": "brittle --mine 0 test/*.js",
    "test:coverage": "brittle --coverage test/*.js", 
    "test:ci": "brittle --bail --coverage --timeout 30000 test/*.js",
    "test:debug": "brittle --trace --unstealth test/*.js",
    "test:solo": "brittle --solo test/*.js"
  }
}

Environment Variables

CLI options can be controlled via environment variables in some cases:

# Using environment variables
BRITTLE_TIMEOUT=30000 npx brittle test/*.js
BRITTLE_COVERAGE=1 npx brittle test/*.js

# In package.json
{
  "scripts": {
    "test": "BRITTLE_TIMEOUT=10000 brittle test/*.js"
  }
}

Output Control

TAP Output

All runtimes produce TAP (Test Anything Protocol) compliant output:

# Standard TAP output
npx brittle test/*.js
# TAP version 13
# ok 1 - test name
# 1..1
# # tests = 1/1 pass
# # asserts = 1/1 pass
# # time = 5ms
# # ok

Quiet Mode with Coverage

# Minimal output with coverage
npx brittle --coverage test/*.js > /dev/null
# Still generates coverage reports

Exit Codes

Brittle uses standard exit codes:

  • 0 - All tests passed
  • 1 - One or more tests failed
  • 2 - Configuration or runtime error
# Use exit code in scripts
npx brittle test/*.js && echo "Tests passed" || echo "Tests failed"

# CI integration
npx brittle --bail test/*.js
if [ $? -eq 0 ]; then
  echo "Deployment ready"
else
  echo "Tests failed, stopping deployment"
  exit 1
fi