Assertion Block Syntax
Wrap assertions in>>> and <<< markers:
==, you can omit it:
Assertion Subjects
Equality and Comparison
Compare values using standard comparison operators.String Operators
Match, search, and compare string values.Regular expressions in
matches are enclosed in forward slashes: /pattern/. The pattern uses Go’s regexp syntax.Existence and Type
Check whether values exist and validate their types.
Supported types for the
type operator: null, boolean, number, string, array, object.
Length and Arrays
Validate array lengths and check array contents.The each Operator
each applies an assertion to every element in an array. It is useful for validating the shape of list responses:
The in Operator
in checks whether a value is a member of a set. List values in square brackets:
The includes Operator
includes checks whether an array contains a specific value:
Schema Validation
Validate the entire response body against a JSON Schema file.schemas/user.json contains a standard JSON Schema:
Schema file paths are resolved relative to the
.http file that references them.Snapshot Testing
Compare the response body against a previously saved baseline. On first run, the snapshot is created. On subsequent runs, the response is compared against it.__snapshots__ directory next to your test file. Update them when the response intentionally changes:
Combining Assertions
A single assertion block can mix operators from any category:Header Assertions
Assert on response headers using theheader <name> subject: