Skip to content

Test a response

A request can carry tests: assertions evaluated against its own response on every send. The same assertion shape is used by a chain’s assert node, and one evaluator in the engine serves both.

The Form view’s Tests tab edits them. In YAML:

- name: Create user
method: POST
url: "{{baseUrl}}/users"
body:
contentType: application/json
content: '{"email":"a@example.com"}'
tests:
- source: status
op: eq
expected: "201"
- source: body
path: id
op: exists
- source: header
path: content-type
op: contains
expected: application/json

An assertion is a source, an optional path, an op, and an optional expected.

sourceWhat path means
status— (unused)
bodyA dotted JSON path, e.g. data.items.0.id
headerThe header name, e.g. content-type
varA variable name — read from the active environment for a request test, or from chain scope in an assert node
opMeaning
eqEquals expected
neDoes not equal expected
containsexpected occurs in the value
gtNumerically greater than expected
ltNumerically less than expected
existsThe value is present — expected is unused
matchesThe value matches the regular expression in expected

expected is a string, so quote a number in YAML (expected: "201"), and it may itself contain {{variables}}.

The response pane gets a pass/fail strip and a Tests tab listing each assertion with what it expected and what it got. Run history stores results too, with a passed/total pill on the row — so you can see when an endpoint started failing, not just that it fails now.

SSE streaming sends do not evaluate tests. A request whose Accept is text/event-stream streams events rather than producing one buffered response, so there is nothing for the assertions to run against.

An empty test list is dropped rather than written, so a request never gains tests: [] and your diffs stay minimal.

The assert node takes the same list. All assertions passing routes to the pass branch; any failure routes to fail — which means a chain can check its own intermediate state and take a different path instead of just stopping.

- id: check-created
type: assert
position: { x: 400, y: 120 }
assertions:
- source: status
op: eq
expected: "201"

This vocabulary — four sources, seven operators — is what v0.1.0-preview.9 ships. If you have read about asserting on response duration, size, or cookies, or about validating a body against the spec’s declared schema, those are later work and are not in this release.