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.
Targets
Section titled “Targets”| 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 |
Operators
Section titled “Operators”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
In the command line and exports
Section titled “In the command line and exports”courier runruns# @assertchecks and counts failures as failed tests.- Bruno
assertblocks import as# @assertlines, one to one. - Postman export turns checks into
pm.test(…)lines.