Assertions
Assertions
Section titled “Assertions”The @assert directive validates conditions on the response. Failed assertions display ❌ in the results panel.
Syntax
Section titled “Syntax”@assert target operator [expectedValue]Targets
Section titled “Targets”| Target | Description | Example |
|---|---|---|
status | HTTP status code | @assert status == 200 |
body | Response body (JSON path) | @assert body.success == true |
header | Response headers | @assert header.content-type contains application/json |
duration | Response time in ms | @assert duration < 2000 |
size | Response size in bytes | @assert size < 10240 |
cookie | Response cookies | @assert cookie.sessionId exists |
Comparison Operators
Section titled “Comparison Operators”| Operator | Description | Example |
|---|---|---|
== | Equals | @assert status == 200 |
!= | Not equals | @assert status != 500 |
> | Greater than | @assert body.items.length > 0 |
< | Less than | @assert duration < 2000 |
>= | Greater than or equal | @assert status >= 200 |
<= | Less than or equal | @assert status <= 299 |
contains | Contains text | @assert body.name contains John |
Type & Existence Operators
Section titled “Type & Existence Operators”| Operator | Description | Example |
|---|---|---|
exists | Not null/undefined | @assert body.token exists |
!exists | Is null/undefined | @assert body.error !exists |
isArray | Is an array | @assert body.data isArray |
isNumber | Is numeric | @assert body.count isNumber |
isNull | Is null | @assert body.deletedAt isNull |
isUndefined | Is undefined | @assert body.debug isUndefined |
isEmpty | Is empty | @assert body.errors isEmpty |
Complete Example
Section titled “Complete Example”###@name Create UserPOST {{baseUrl}}/usersContent-Type: application/json
{ "name": "John", "email": "john@example.com"}
@assert status == 201@assert body.id exists@assert body.name == John@assert body.email contains @@assert body.roles isArray@assert header.content-type contains application/json@assert duration < 3000@assert size < 5120Next Steps
Section titled “Next Steps”- Explore retry and timeout settings
- See a complete example with all features combined