CLI for Jasmine, a simple JavaScript testing framework for browsers and Node
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Jasmine provides a full-featured command-line interface with sub-commands, extensive options, and environment variable support for integrating into development workflows and CI/CD pipelines.
Execute the Jasmine CLI with various commands and options.
jasmine [command] [options] [files] [--]
# Run all tests
jasmine
# Run specific files
jasmine spec/unit/user-spec.js spec/integration/api-spec.js
# Run with options
jasmine --parallel=4 --filter="authentication" --verboseAvailable commands for project initialization and management.
# Initialize jasmine project structure
jasmine init
# Install example specs and helpers
jasmine examples
# Show help information
jasmine help
jasmine -h
# Show version information
jasmine version
jasmine -v
# Enumerate suites and specs without running
jasmine enumerateSub-command Examples:
# Initialize new project
npx jasmine init
# Creates: spec/support/jasmine.mjs
# Add example files
npx jasmine examples
# Creates: spec/jasmine_examples/, lib/jasmine_examples/, spec/helpers/jasmine_examples/
# Check versions
npx jasmine version
# Output: jasmine v5.10.0, jasmine-core v5.10.0
# List all suites and specs
npx jasmine enumerate
# Output: JSON structure of all test suites and specsControl parallel test execution with worker process configuration.
# Run with specific number of workers
jasmine --parallel=4
# Auto-detect optimal worker count
jasmine --parallel=auto
# Combine with other options
jasmine --parallel=auto --verbose --no-colorParallel Examples:
# Use 4 worker processes
npx jasmine --parallel=4
# Auto-detect workers (CPU count - 1)
npx jasmine --parallel=auto
# Parallel with filtering
npx jasmine --parallel=4 --filter="integration"
# Note: --filter-path not supported in parallel modeFilter which specs to run using various criteria.
# Filter specs by regular expression
jasmine --filter=REGEX
# Filter specs by suite/spec path (not supported in parallel mode)
jasmine --filter-path='["suite name","spec name"]'
# Examples
jasmine --filter="authentication"
jasmine --filter="^User.*should"
jasmine --filter-path='["User management","Authentication","should validate credentials"]'Filtering Examples:
# Run only integration tests
npx jasmine --filter="integration"
# Run specs matching specific pattern
npx jasmine --filter="^API.*should respond"
# Run specific spec by path (sequential mode only)
npx jasmine --filter-path='["UserService","authenticate","should reject invalid credentials"]'
# Combine filtering with specific files
npx jasmine spec/user-spec.js --filter="authentication"Configure helper files and required modules.
# Load helper files matching pattern
jasmine --helper=PATTERN
# Require modules before execution
jasmine --require=MODULE
# Examples
jasmine --helper="helpers/**/*.js"
jasmine --require="@babel/register"
jasmine --require="tsconfig-paths/register"File Loading Examples:
# Load specific helper files
npx jasmine --helper="spec/helpers/database-helper.js"
# Load helper files with glob pattern
npx jasmine --helper="spec/helpers/**/*.js"
# Require transpiler
npx jasmine --require="@babel/register"
# Multiple requires
npx jasmine --require="@babel/register" --require="tsconfig-paths/register"
# Combine options
npx jasmine --helper="spec/helpers/**/*.js" --require="@babel/register"Control test execution behavior and failure handling.
# Stop execution on first failure
jasmine --fail-fast
# Control randomization
jasmine --random=true
jasmine --random=false
# Set random seed for reproducible runs
jasmine --seed=12345
# Combine execution controls
jasmine --fail-fast --random=true --seed=54321Execution Control Examples:
# Stop on first failure for fast feedback
npx jasmine --fail-fast
# Disable randomization for debugging
npx jasmine --random=false
# Use specific seed for reproducible test runs
npx jasmine --seed=12345
# Fast failure with specific seed
npx jasmine --fail-fast --seed=12345Control test output formatting and verbosity.
# Control color output
jasmine --color
jasmine --no-color
# Enable verbose output
jasmine --verbose
# Use custom reporter
jasmine --reporter=PATH_TO_REPORTER
# Examples
jasmine --no-color --verbose
jasmine --reporter="./custom-reporter.js"Output Examples:
# Force color output (useful in CI)
npx jasmine --color
# Disable colors for log files
npx jasmine --no-color > test-results.log
# Verbose output for debugging
npx jasmine --verbose
# Custom reporter
npx jasmine --reporter="./reporters/junit-reporter.js"
# Combine output options
npx jasmine --no-color --verbose --reporter="./reporters/custom.js"Specify configuration files and override defaults.
# Use custom configuration file
jasmine --config=PATH
# Examples
jasmine --config="config/test.json"
jasmine --config="spec/support/ci.mjs"Configuration Examples:
# Use CI-specific configuration
npx jasmine --config="config/ci.json"
# Use development configuration
npx jasmine --config="spec/support/dev.mjs"
# Override config with CLI options
npx jasmine --config="config/base.json" --parallel=4 --verboseConfigure Jasmine using environment variables.
# Set configuration file path
JASMINE_CONFIG_PATH=path/to/config.json jasmine
# Set environment variables inline
NODE_ENV=test DATABASE_URL=test://localhost jasmine
# Examples
JASMINE_CONFIG_PATH=config/ci.json npx jasmine
NODE_ENV=test npx jasmine --parallel=autoEnvironment Variable Examples:
# Use environment-specific config
JASMINE_CONFIG_PATH=config/production-test.json npx jasmine
# Set test environment
NODE_ENV=test DATABASE_URL=postgresql://localhost/test_db npx jasmine
# Multiple environment variables
export NODE_ENV=test
export DATABASE_URL=postgresql://localhost/test_db
export JASMINE_CONFIG_PATH=config/ci.json
npx jasmine --parallel=autoSpecify files to run and separate options from file arguments.
# Run specific files
jasmine file1.js file2.js
# Use -- to separate options from files
jasmine --verbose -- spec/integration/*.js
# Mix files with glob patterns
jasmine spec/unit/user-spec.js spec/integration/**/*-spec.jsFile Argument Examples:
# Run specific spec files
npx jasmine spec/unit/user-service-spec.js spec/unit/auth-spec.js
# Run files with glob patterns
npx jasmine "spec/integration/**/*-spec.js"
# Separate options from file patterns
npx jasmine --parallel=4 --verbose -- "spec/**/*-integration-spec.js"
# Override configured spec files
npx jasmine spec/unit/critical-spec.js --fail-fastReal-world usage patterns combining multiple options.
# CI/CD pipeline execution
npx jasmine --config=config/ci.json --parallel=auto --no-color --reporter=./reporters/junit.js
# Development with fast feedback
npx jasmine --fail-fast --verbose --filter="unit"
# Debug specific failing test
npx jasmine spec/problematic-spec.js --random=false --verbose
# Integration test suite
npx jasmine --filter="integration" --parallel=2 --require="./spec/helpers/database-setup.js"
# Load testing with specific configuration
JASMINE_CONFIG_PATH=config/load-test.json NODE_ENV=test npx jasmine --parallel=8 --verboseJasmine CLI returns different exit codes based on test results.
# Exit codes:
# 0 - All tests passed
# 2 - Incomplete (no specs found or suite incomplete)
# 3 - Tests failed
# 4 - Premature exit (process killed during execution)
# 1 - Other errors (configuration, setup, etc.)Exit Code Usage:
# In CI/CD scripts
npx jasmine --parallel=auto
EXIT_CODE=$?
if [ $EXIT_CODE -eq 0 ]; then
echo "All tests passed!"
elif [ $EXIT_CODE -eq 3 ]; then
echo "Tests failed!"
exit 1
else
echo "Test execution error (code: $EXIT_CODE)"
exit 1
fi
# With conditional execution
npx jasmine --fail-fast && npm run build || exit 1