
Basic Test Structure
Common Test Examples
Testing Status Codes
Testing Response Body
Validating the JSON Body with jsonBody
Bruno provides a custom Chai assertion jsonBody to make response-body checks more readable. It’s the native Bruno equivalent of Postman’s pm.response.to.have.jsonBody(...), and supports four call shapes:
Validating against a JSON Schema with jsonSchema
For contract testing, use the jsonSchema assertion to validate a response against a JSON Schema document. Bruno uses Ajv under the hood, so all modern JSON Schema drafts are supported (04, 06, 07, 2019-09, 2020-12) along with the full ajv-formats library.
Built-in formats
Commonajv-formats validators are available out of the box, including email, date, date-time, time, uri, uri-reference, uuid, ipv4, ipv6, hostname, and regex.
Passing Ajv options
You can pass any Ajv options as a second argument — useful, for example, to collect every validation error rather than failing on the first one:Negation
Like
jsonBody, the jsonSchema assertion runs in both the Safe Mode and the Developer Mode, and Postman’s pm.response.to.have.jsonSchema(schema) is automatically translated to expect(res.getBody()).to.have.jsonSchema(schema) on import.Testing Nested Objects
Testing with Conditional Logic
Testing Arrays and Loops
Testing Response Headers
Testing Response Time
Advanced: Saving Values for Next Request
Error Handling
Common Chai Assertions
Next Steps
For more advanced scripting capabilities, see:- Scripting API - Full API reference
- Response Query - Query complex response data
- Variables - Work with variables across requests