Skip to main content

hitspec contract

Verify API contracts against a live provider.

Arguments

Flags

Contract Annotations

Define contract metadata using annotations in your .http files:

State Handler

The --state-handler flag specifies a script that sets up provider state before each interaction. The script receives the state description as an argument:

Examples

Sample Output

Use Cases

  • Consumer-driven contracts — Define what your service expects from its dependencies, then verify those contracts against the real provider.
  • API versioning — Ensure that provider changes do not break existing consumers.
  • CI/CD gates — Run contract verification as part of the provider’s deployment pipeline.

hitspec diff

Compare two JSON test result files to identify regressions, improvements, and changes between test runs.

Arguments

Flags

How It Works

The diff command compares tests by name and file, then categorizes each as: Tests are listed grouped by file (alphabetical) and in request order within each file, so the output is identical on every run. A test that was skipped in the first run has no baseline: its 0 ms duration is not compared, so it is never reported as improved or regressed because of a change in speed. If it now fails, it is reported as regressed; if it now passes, it is unchanged. When the first run has a duration of 0 ms for a test that ran, the percentage change is not defined, so the test is reported as unchanged and excluded from --threshold.

Generating Input Files

First, generate JSON results from your test runs:

Examples

Console Output

Threshold Check

When --threshold is set, the command exits with a non-zero status if any test’s duration increases by more than the specified percentage. This is useful for catching performance regressions in CI:

CI/CD Integration

Last modified on October 19, 2026