hitspec run
Run HTTP API tests defined in.http or .hitspec files.
Arguments
You can pass multiple files, directories and patterns as arguments. See Inputs.
Flags
Core Flags
Output Flags
Execution Flags
Network Flags
A CA, certificate or key file that is missing or not valid PEM, and a malformed
--proxy URL, exit with code 3 before any request is sent. Each of these also has a hitspec.yaml key; see Configuration and TLS, cookies and HTTP options.
History Flags
Every run is recorded to a local history database (also browsable in studio’s History screen).Snapshot Flags
Security Flags
Coverage Flags
Stress Testing Flags
Metrics Flags
Notification Flags
Examples
Basic Usage
Filtering
--tags smok), hitspec prints no requests matched --tags "smok" to stderr and exits with code 64. A filter only needs to match in one of the files of the run. Requests skipped on purpose with @skip still count as matches.
When a selected request has @depends, the requests it depends on are run too (transitively) even if the filters would exclude them, and they are reported like any other request. A dependency that fails still causes its dependents to be skipped.
Quiet Mode
--quiet keeps stdout empty, but it never hides failures:
- With
--output-file, the formatted report is still written to the file. - When anything fails, one line per failed request is written to stderr with the request name and the first failing assertion or error.
- Exit codes are unchanged.
Files That Cannot Be Loaded
A file with a syntax error, a duplicate@name, or a circular @depends does not stop the run. The remaining files still run, the error is written to stderr (for example 1 file failed to parse), and the run exits with code 2. With --output json, junit, tap or html, the broken file also appears in the report as an error entry.
Parallel Execution
Requests with dependencies (
@depends) always run sequentially. Only independent requests run in parallel. Captured variables are not shared between parallel requests.Watch Mode
--watch re-runs when a test file changes, including editors that save by renaming a temp file over it, and when hitspec.yaml, --config or the env file changes. The settings are reloaded before the next pass, and --output-file is rewritten each time. node_modules, vendor and .git are not watched. With --cookies, the cookie jar is kept across re-runs.
Inputs
hitspec run - reads one document from stdin. Relative paths in it resolve against the working directory. It cannot be combined with other files, --watch or --stress; --dry-run works with it.
hitspec run 'tests/**/*.http'. ** matches any depth.
Directories are searched recursively, skipping .git, node_modules and vendor unless you name one of them explicitly. A file given more than once runs once. A pattern or path that matches no .http or .hitspec file is an error (exit code 1); so is empty stdin. Combining - with other files, --watch or --stress exits with code 64.
Ctrl+C (or SIGTERM) stops the run: hitspec reports the requests that finished, marks the rest as cancelled, writes --output-file, and exits with code 130. A second Ctrl+C exits immediately.
Verbose Output
-v can be repeated; each level adds detail for every request, not only failures.
Warnings (a capture that matched nothing, a
{{reference}} sent unresolved) print in yellow under the request at every level, and are also written to stderr. They never change the exit code.
Dry Run
--dry-run parses each file and prints what would run, in execution order, without sending anything or touching the history database.
{{login.token}}) are left as written. Requests that would not run are marked - with the reason: the @skip text, filtered out, condition not met, or dependency will not run. An @if that depends on a captured value is listed with a note, because only a real run can decide it. --name and --tags apply as in a real run.
--dry-run cannot be combined with --stress (usage error, exit 64; nothing is sent). With --dry-run, -o and --output-file are ignored: the plan is always text (a note on stderr says so) and the output file is not created.
Exit codes: 0 on success, 2 if a file cannot be loaded (syntax error, duplicate @name, @depends cycle), 64 if the filters match nothing.
Output Formats
Stress Testing
CI/CD Integration
Snapshot Testing
Security Flags
Exit Codes
When several apply:
130, then 2, then 4, then 1, then 64. See Exit Codes.