Skip to main content
Bruno provides a comprehensive assertion system for validating API responses. Use assertions to verify status codes, check response data, validate schemas, and ensure your APIs behave correctly.

Assertion Methods

Bruno supports two ways to write assertions:

Inline Assertions

Quick assertions in the assert block

Test Scripts

Complex validations using JavaScript and Chai

Inline Assertions

Inline assertions provide a simple, declarative way to validate responses without writing JavaScript.

Basic Syntax

Assertion Operators

Bruno supports a rich set of operators for different validation needs:
operator
Equal to
operator
Not equal to
operator
Greater than
operator
Greater than or equal to
operator
Less than
operator
Less than or equal to
operator
Value is in list
operator
Value is not in list
operator
String/array contains value
operator
String/array does not contain value
operator
String starts with value
operator
String ends with value
operator
Matches regular expression
operator
Does not match regular expression
operator
Length equals value
operator
Value is between min and max (inclusive)
operator
Value is null
operator
Value is undefined
operator
Value is not undefined
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
operator
Value is empty (string, array, or object)
operator
Value is not empty
operator
Value is truthy (true, non-zero number, non-empty string)
operator
Value is falsy (false, 0, empty string, null, undefined)

Real-World Examples

Test Scripts

For complex validations, use test scripts with the full power of JavaScript and Chai assertion library.

Basic Test Structure

Chai Assertions

Bruno includes the Chai assertion library with three assertion styles:

Advanced Validation Patterns

Async Test Validations

Error Handling in Tests

Best Practices

1

Use Descriptive Test Names

2

Test One Thing Per Assertion

3

Validate Data Types and Structure

4

Use Inline Assertions for Simple Checks

Common Patterns

Status Code Validation

Email Validation

Array Validation

Performance Checks

Scripting

Learn advanced scripting techniques

Variables

Understand variable scopes and usage

Workflows

Build complex request workflows

Testing APIs

Testing fundamentals and best practices