hitspec.yaml (or hitspec.yml) file in your project root (hitspec also finds it from a subdirectory of the project; see Config File Search). All settings are optional — hitspec uses sensible defaults when no config file is present.
Creating a Config File
Runhitspec init to generate a starter configuration:
hitspec.yaml and an example.http file.
Full Configuration Reference
Options Reference
General
Network
Relative
cacert, cert and key paths in hitspec.yaml resolve against the directory of the file; a bad or missing file exits with code 3. See TLS, cookies and HTTP options.
Headers
Output
Execution
verbose: true is applied by hitspec run and means -v. A -v, -vv or -vvv flag wins over it, and --verbose=0 turns it off. The key must be a boolean. noColor: true is applied by hitspec run too: --no-color (or --no-color=false) on the command line wins, then HITSPEC_NO_COLOR, then the file. The NO_COLOR environment variable is also honored and can only turn colors off.Reporters and outputDir
hitspec run writes one report per entry of reporters. console always goes to stdout. With outputDir set, every other reporter writes a file there, replaced on each run (and on each --watch pass):
- A relative
outputDiris relative to the directory of the config file that sets it, not to the working directory. hitspec creates it before the run when at least one reporter writes a file there. - Without
outputDir, every reporter writes to stdout, so only one is allowed.reporters: [junit]is the same as-o junit. Listing two or more exits with code3. - An unknown reporter name exits with code
3. Duplicates are ignored. An empty list means["console"]. -o/--outputor--output-fileon the command line, or a non-emptyHITSPEC_OUTPUTorHITSPEC_OUTPUT_FILE, replace both keys: they are not read at all.--quietdrops the report on stdout. The files are still written.- When no report goes to stdout (for example
reporters: [junit]withoutputDir: reports), the failed requests are listed on stderr, as with--quiet. --stressand--dry-runignore both keys.
Environments
Define per-environment variables inline:--env:
{{variableName}} interpolation in your test files.
Stress Testing Profiles
Define reusable stress test profiles:
Use a profile with the
--profile flag:
Config File Search
hitspec picks the config file in this order:- the path given with
--config(orHITSPEC_CONFIG) — used as is; - otherwise the nearest
hitspec.yaml(thenhitspec.yml) found by looking in the working directory and then in each parent directory.
.git
(your project root, after checking that directory itself), it never reads a
config file from your home directory or from anything above it, and it stops at
the filesystem root. If nothing is found, all default values are used.
The working directory is where you ran the command for hitspec run,
hitspec validate and hitspec contract verify, and the workspace directory
for hitspec studio and hitspec serve. hitspec mcp serve never looks
outside its workspace: a hitspec.yaml above the workspace root is ignored.
Run hitspec run -v to print the config file in use on stderr.
A config file that cannot be parsed stops the command with exit code 3 and a
file:line message. An unknown key is only a warning:
hitspec validate --strict
turns the warning into an error (exit code 2), which makes it a good CI check.
Precedence
Every command that sends requests —hitspec run (including --stress),
hitspec contract verify, hitspec studio and hitspec serve --api-only —
resolves a setting the same way. From highest to lowest priority:
- a command-line flag (for example
--timeout), - a
HITSPEC_*environment variable, hitspec.yaml,- the built-in default.
--env / HITSPEC_ENV pair, belong to hitspec run. The
other commands read the same variables for everything except the environment
name.
A
@retry or @retryDelay annotation on a request overrides retries and
retryDelay for that request, and a request’s own headers override headers.
A number at or below zero in hitspec.yaml counts as “not set” (use
followRedirects: false rather than maxRedirects: 0). The exception is
maxResponseBytes, where 0 means the default and -1 means no limit.
hitspec studio, hitspec serve --api-only and hitspec contract verify have
no run flags. They read HITSPEC_TIMEOUT, HITSPEC_PROXY, HITSPEC_INSECURE,
HITSPEC_PARALLEL, HITSPEC_CONCURRENCY and HITSPEC_BAIL, plus the TLS and HTTP
variables from the table above (HITSPEC_CACERT, HITSPEC_CERT, HITSPEC_KEY,
HITSPEC_HTTP1, HITSPEC_COOKIES, HITSPEC_MAX_RESPONSE_BYTES,
HITSPEC_REDIRECT_FORWARD_HEADERS), then hitspec.yaml, then the defaults. Studio and serve choose the environment with their own
--env (else defaultEnvironment, else dev) and ignore HITSPEC_ENV.
contract verify finds hitspec.yaml from the current directory upward (or uses
the path in HITSPEC_CONFIG) and has no environment of its own.