Skip to main content
Bruno uses the Chai library for assertions. All Chai expect syntax works in Bruno tests.
Write JavaScript test scripts to validate API responses, handle complex logic, and automate testing workflows. bru test script

Basic Test Structure

Common Test Examples

Testing Status Codes

Testing Response Body

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

Bruno-specific assertions

In addition to the standard Chai assertions, Bruno registers custom assertions for working with JSON response bodies.

jsonBody

Use jsonBody to validate the response body against a value or to check for the existence of a nested property. This assertion mirrors Postman’s pm.response.to.have.jsonBody(...) API and is convenient for collections imported from Postman.
All variants support negation via .not (for example, to.not.have.jsonBody("key")).

jsonSchema

Use jsonSchema to validate a response body against a JSON Schema. Bruno uses Ajv under the hood, so any JSON Schema draft supported by Ajv works here. An optional second argument forwards options to the Ajv instance.
When the body fails validation, the assertion error includes the Ajv validation errors so you can quickly see which fields are missing or have the wrong type.

Next Steps

For more advanced scripting capabilities, see: