Skip to content

Assertions

The Assert tab is a table of checks that run after each response. Each row is saved as a # @assert line:

# @assert res.status eq 200
# @assert res.headers.content-type contains json
# @assert res.body.$.items length 3
# @assert res.body.$.total between [1, 100]
# @assert res.body matchesSchema {"type":"object","required":["id"]}

Checks run as tests after the response handler. Results show in the response’s Tests tab, next to script tests.

Target Value
res.status The status code
res.body The whole body
res.body.$.path A JSONPath into the body
res.headers.name A response header

Comparing: eq, neq, gt, gte, lt, lte, between

Lists and text: in, notIn, contains, notContains, startsWith, endsWith, matches, notMatches (regular expressions), length

Schema: matchesSchema takes a JSON Schema. It supports the same subset as courier.validateSchema.

No value needed: isEmpty, isNotEmpty, isNull, isDefined, isUndefined, isTruthy, isFalsy, isNumber, isString, isBoolean, isArray, isJson

  • courier run runs # @assert checks and counts failures as failed tests.
  • Bruno assert blocks import as # @assert lines, one to one.
  • Postman export turns checks into pm.test(…) lines.