Skip to main content

hitspec run

Run HTTP API tests defined in .http or .hitspec files.
hitspec run <file|directory> [flags]

Arguments

ArgumentDescription
<file>Single .http or .hitspec file to run
<directory>Directory containing test files (searched recursively)
You can pass multiple files and directories as arguments.

Flags

Core Flags

FlagShortDescriptionDefaultEnv Var
--env-eEnvironment name to usedevHITSPEC_ENV
--env-filePath to .env file for variable interpolationHITSPEC_ENV_FILE
--configPath to config file (hitspec.yaml)HITSPEC_CONFIG
--name-nRun only tests matching name pattern
--tags-tRun only tests with specified tags (comma-separated)HITSPEC_TAGS

Output Flags

FlagShortDescriptionDefaultEnv Var
--verbose-vVerbose output (use -vv or -vvv for more detail)false
--quiet-qSuppress all output except errorsfalseHITSPEC_QUIET
--no-colorDisable colored outputfalseHITSPEC_NO_COLOR
--output-oOutput format: console, json, junit, tap, htmlconsoleHITSPEC_OUTPUT
--output-fileWrite output to a file instead of stdoutHITSPEC_OUTPUT_FILE

Execution Flags

FlagShortDescriptionDefaultEnv Var
--bailStop on first failurefalseHITSPEC_BAIL
--timeoutRequest timeout (e.g., 30s, 1m, 500ms)30sHITSPEC_TIMEOUT
--dry-runParse and show what would run without executingfalse
--parallel-pRun independent requests in parallelfalseHITSPEC_PARALLEL
--concurrencyMax concurrent requests when running in parallel5HITSPEC_CONCURRENCY
--watch-wWatch files for changes and re-run testsfalse

Network Flags

FlagShortDescriptionDefaultEnv Var
--proxyProxy URL for HTTP requestsHITSPEC_PROXY
--insecure-kDisable SSL certificate validationfalseHITSPEC_INSECURE

Snapshot Flags

FlagDescriptionDefault
--update-snapshotsUpdate snapshot files instead of comparing against themfalse

Security Flags

FlagDescriptionDefault
--allow-shellAllow shell command execution (>>>shell blocks and hooks)false
--allow-dbAllow database assertions (>>>db blocks)false

Coverage Flags

FlagDescriptionDefault
--coverageGenerate API coverage report against OpenAPI specfalse
--openapiPath to OpenAPI spec file for coverage analysis
Shell and database blocks are disabled by default for security. You must explicitly opt in with --allow-shell or --allow-db when your test files use these features.

Stress Testing Flags

FlagShortDescriptionDefault
--stressEnable stress testing modefalse
--duration-dStress test duration (e.g., 30s, 5m, 1h)30s
--rate-rTarget requests per second10
--vusNumber of virtual users (alternative to --rate)0
--max-vusMaximum concurrent requests100
--think-timeThink time between requests per virtual user0s
--ramp-upRamp-up time to reach target rate/VUs0s
--thresholdPass/fail thresholds (e.g., "p95<200ms,errors<0.1%")
--profileLoad a stress profile from config file
--no-progressDisable real-time progress displayfalse
--stress-jsonOutput stress results as JSONfalse

Metrics Flags

FlagDescriptionDefaultEnv Var
--metricsExport format: prometheus, datadog, jsonHITSPEC_METRICS
--metrics-portPort for Prometheus metrics HTTP endpoint9090HITSPEC_METRICS_PORT
--metrics-fileOutput file for JSON metricsHITSPEC_METRICS_FILE
--datadog-api-keyDataDog API keyDD_API_KEY
--datadog-siteDataDog sitedatadoghq.comDD_SITE
--datadog-tagsComma-separated DataDog tagsDD_TAGS

Notification Flags

FlagDescriptionDefaultEnv Var
--notifyNotification service: slack, teamsHITSPEC_NOTIFY
--notify-onWhen to notify: always, failure, success, recoveryfailureHITSPEC_NOTIFY_ON
--slack-webhookSlack webhook URLSLACK_WEBHOOK
--slack-channelSlack channel overrideSLACK_CHANNEL
--teams-webhookMicrosoft Teams webhook URLTEAMS_WEBHOOK

Examples

Basic Usage

hitspec run tests/api.http

Filtering

# Run only smoke-tagged tests
hitspec run tests/ --tags smoke

# Multiple tags (OR logic)
hitspec run tests/ --tags smoke,critical

# Filter by name pattern (glob matching)
hitspec run tests/ --name "User*"
hitspec run tests/ --name "*Profile"

# Combine filters
hitspec run tests/ --tags smoke --name "*Auth*"

Parallel Execution

# Run independent requests in parallel
hitspec run tests/ --parallel

# Set concurrency limit
hitspec run tests/ --parallel --concurrency 10
Requests with dependencies (@depends) always run sequentially. Only independent requests run in parallel. Captured variables are not shared between parallel requests.

Watch Mode

# Watch files and re-run on changes
hitspec run tests/ --watch

# Combine with tags for focused development
hitspec run tests/ --watch --tags dev

Output Formats

hitspec run tests/

Stress Testing

hitspec run api.http --stress --duration 1m --rate 100

CI/CD Integration

# GitHub Actions example
hitspec run tests/ \
  --env staging \
  --output junit \
  --output-file test-results.xml \
  --bail
# With notifications on failure
hitspec run tests/ \
  --env staging \
  --notify slack \
  --slack-webhook "$SLACK_WEBHOOK" \
  --notify-on failure

Snapshot Testing

# First run creates snapshots in __snapshots__/
hitspec run tests/

# Update snapshots when expected changes occur
hitspec run tests/ --update-snapshots

Security Flags

# Allow shell blocks and database assertions
hitspec run tests/ --allow-shell --allow-db

# Only allow shell execution
hitspec run tests/ --allow-shell

Exit Codes

CodeConstantDescription
0ExitSuccessAll tests passed
1ExitTestFailureOne or more tests failed
2ExitParseErrorFile parsing error (invalid syntax)
3ExitConfigErrorConfiguration error
4ExitNetworkErrorNetwork or connection error
64ExitUsageErrorInvalid CLI usage

Environment Variables

All flags that support environment variables are listed in the flag tables above. Environment variables are read at startup and can be overridden by explicit flags. Common variables:
export HITSPEC_ENV=staging
export HITSPEC_TIMEOUT=60s
export HITSPEC_OUTPUT=json
export HITSPEC_BAIL=true
export HITSPEC_PARALLEL=true
export HITSPEC_CONCURRENCY=10