- Declarative assertions - Simple assertions in the
assertblock - Test scripts - JavaScript test functions in the
testsblock
Declarative Assertions
Theassert block provides a simple, declarative syntax for common assertions:
Assertion Operators
Assertions use the format:expression: operator value
Comparison Operators
Equal to (default if no operator specified)
Not equal to
Greater than
Greater than or equal to
Less than
Less than or equal to
Collection Operators
Value is in array
Value is not in array
String/array contains value
String/array does not contain value
String Operators
String starts with value
String ends with value
Matches regular expression
Does not match regular expression
Size/Length Operators
Array/string has exact length
Value is between two numbers (inclusive)
State Operators (Unary)
These operators don’t require a value:Value is empty (array, string, or object)
Value is not empty
Value is null
Value is undefined
Value is defined (not undefined)
Value is truthy
Value is falsy
Type Operators (Unary)
Value is a JSON object
Value is a number
Value is a string
Value is a boolean
Value is an array
Assertion Examples
Test Scripts
For more complex validations, use thetests block with JavaScript:
Test Function
Defines a test caseParameters:
description(string) - Test descriptioncallback(function) - Test function (can be async)
Chai Assertions
Bruno includes the Chai assertion library with BDD-style assertions.Expect API
Theexpect function is the primary assertion method:
Assert API
Alternatively, use theassert 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