Skip to main content
Bruno provides two ways to validate HTTP responses:
  1. Declarative assertions - Simple assertions in the assert block
  2. Test scripts - JavaScript test functions in the tests block

Declarative Assertions

The assert block provides a simple, declarative syntax for common assertions:

Assertion Operators

Assertions use the format: expression: operator value

Comparison Operators

operator
Equal to (default if no operator specified)
operator
Not equal to
operator
Greater than
operator
Greater than or equal to
operator
Less than
operator
Less than or equal to

Collection Operators

operator
Value is in array
operator
Value is not in array
operator
String/array contains value
operator
String/array does not contain value

String Operators

operator
String starts with value
operator
String ends with value
operator
Matches regular expression
operator
Does not match regular expression

Size/Length Operators

operator
Array/string has exact length
operator
Value is between two numbers (inclusive)

State Operators (Unary)

These operators don’t require a value:
operator
Value is empty (array, string, or object)
operator
Value is not empty
operator
Value is null
operator
Value is undefined
operator
Value is defined (not undefined)
operator
Value is truthy
operator
Value is falsy

Type Operators (Unary)

operator
Value is a JSON object
operator
Value is a number
operator
Value is a string
operator
Value is a boolean
operator
Value is an array

Assertion Examples

Test Scripts

For more complex validations, use the tests block with JavaScript:

Test Function

function
Defines a test caseParameters:
  • description (string) - Test description
  • callback (function) - Test function (can be async)

Chai Assertions

Bruno includes the Chai assertion library with BDD-style assertions.

Expect API

The expect function is the primary assertion method:

Assert API

Alternatively, use the assert style:

Chaining Assertions

Chain multiple assertions for better readability:

Common Test Patterns

Status Code Validation

Response Body Validation

Array Validation

Header Validation

Response Time Validation

JWT Token Validation

Schema Validation

Combining Assertions and Tests

You can use both declarative assertions and test scripts together:

Next Steps

Pre-request Scripts

Modify requests before sending

Post-response Scripts

Process responses and extract data