Skip to main content
hitspec provides 26 assertion operators organized into six categories. Every assertion follows this pattern:
When the operator is ==, you can omit it: expect status 200 is shorthand for expect status == 200.

Equality and Comparison (6 operators)

Numeric comparison coerces strings to numbers when possible. "42" and 42 are considered equal by ==.

String Operators (5 operators)

Regular expressions use Go’s regexp syntax and are enclosed in forward slashes: /pattern/.

Existence and Type (3 operators)

Supported type values: null, boolean, number, string, array, object.

Length Operators (5 operators)

Works on strings, arrays, and objects (counts keys).

Array Operators (5 operators)

includes / !includes

Checks whether an array contains (or does not contain) a specific value:

in / !in

Checks whether a scalar value is a member of a set. List values in square brackets:

each

Applies an assertion to every element in an array. Useful for validating list shapes:
You can also use each with an operator/value map:

Schema and Snapshot (2 operators)

schema

Validates the response body against a JSON Schema file. File paths are relative to the .http file.

snapshot

Compares the response body against a previously saved baseline. On first run, the snapshot is created. On subsequent runs, differences cause failure.
Update snapshots when the response intentionally changes:

Quick Reference

Last modified on February 10, 2026