Assertions
Assert on your step's response, inter-service traffic, and console logs.
Each step can have an assertions array of blocks. Block type is determined by shape — there are three kinds:
Self block
Asserts on the step's own response (HTTP response or DB query result). A self block has no match or service field.
{
"assertions": [
{ "path": "response.status", "operator": "eq", "value": 201 },
{ "path": "response.body.id", "operator": "exists" },
{ "path": "response.body.name", "operator": "eq", "value": "{{userName}}" },
{ "path": "response.header.content-type", "operator": "contains", "value": "application/json" },
{ "path": "responseTime", "operator": "lt", "value": 500 }
]
} HTTP call block
Asserts on inter-service traffic captured by the interceptor sidecar. Identified by the presence of a match field.
{
"match": {
"origin": "api-gateway",
"method": "POST",
"url": "user-service/api/users"
},
"count": { "operator": "eq", "value": 1 },
"assertionScope": "all",
"assertions": [
{ "path": "request.body.email", "operator": "eq", "value": "{{email}}" },
{ "path": "response.status", "operator": "eq", "value": 201 },
{ "path": "response.body.id", "operator": "exists" }
]
} Match fields
All optional, all support {{variables}}:
| Field | Description |
|---|---|
origin | Service name that made the request |
method | HTTP method to match |
url | Target URL: service-name/path, service-name, or /path |
assertionScope
Determines which matching traffic entries are validated:
| Value | Behavior |
|---|---|
all (default) | All matching entries must pass all assertions |
first | Only the first matching entry is validated |
last | Only the last matching entry is validated |
any | At least one matching entry must pass all assertions |
count
Asserts on the number of matching traffic entries:
"count": { "operator": "eq", "value": 1 } Operators: eq, gt, gte, lt, lte. Default: { "operator": "gte", "value": 1 } (at least one match expected).
Console log block
Asserts on console output from a specific service during the step group's execution. Identified by the presence of a service field.
{
"service": "user-service",
"consoleAssertions": [
{
"level": "INFO",
"message": { "operator": "contains", "value": "User created" },
"count": { "operator": "gte", "value": 1 }
},
{
"level": "ERROR",
"count": { "operator": "eq", "value": 0 }
},
{
"message": { "operator": "matches", "value": "Processing order \\d+" },
"count": { "operator": "gte", "value": 1 }
}
]
} ConsoleLogAssertion fields
| Field | Type | Required | Description |
|---|---|---|---|
level | enum | No | Filter by log level: INFO, WARN, ERROR, DEBUG. If omitted, matches all levels. |
message | object | No | Filter by message content. Has operator (eq, contains, matches) and value (supports {{variables}}). |
count | object | Yes | Assert on count of matching logs: { "operator": "eq", "value": 0 } |
Assertion paths
HTTP responses (self block or HTTP call block)
| Path | Description |
|---|---|
response.status | HTTP status code (integer) |
response.body | Entire response body |
response.body.field | Top-level field in response body |
response.body.nested.field | Nested field (dot notation) |
response.body[0].field | Array element access |
response.header.header-name | Response header (case-insensitive) |
request.method | HTTP method of the request |
request.body | Entire request body |
request.body.field | Field in request body |
request.header.header-name | Request header (case-insensitive) |
responseTime | Response time in milliseconds |
Database query results (self block only)
| Path | Description |
|---|---|
success | Boolean — did the query succeed? |
data | Array of result rows |
data[0].column | Specific column from a result row |
rowsAffected | Number of affected rows (integer) |
error | Error message if query failed |
Operators
| Operator | Value required? | Value type | Description |
|---|---|---|---|
eq | Yes | any | Exact equality (case-insensitive for strings) |
ne | Yes | any | Not equal |
gt | Yes | number | Greater than |
gte | Yes | number | Greater than or equal |
lt | Yes | number | Less than |
lte | Yes | number | Less than or equal |
contains | Yes | string | Substring match (case-insensitive) |
notContains | Yes | string | Substring does NOT match |
matches | Yes | string (regex) | Regular expression match |
exists | No | — | Value exists (defined and not null) |
notExists | No | — | Value does not exist |
in | Yes | array | Value is in the given array |
notIn | Yes | array | Value is NOT in the given array |
type | Yes | string | Type check: string, number, boolean, object, array, null |
length | Yes | number | Array or string length equals value |
isEmpty | No | — | Value is empty/null/undefined/empty array/empty object |
notEmpty | No | — | Value is not empty |
arrayContains | Yes | any | Array contains the given element |
arrayNotContains | Yes | any | Array does NOT contain the given element |