The
rq.expect object provides assertion methods for writing tests in Requestly. It is built on top of the popular Chai.js assertion library, giving you access to powerful and expressive assertions for validating API responses.
Using Chai.js: Requestly uses the Chai.js BDD assertion library. For the complete list of assertions and advanced features, refer to the Chai.js official documentation.
Basic Usage
Therq.expect function is used within test functions created by rq.test to assert expected conditions:
Common Assertions
Below are some commonly used Chai.js assertions. For a complete reference, visit the Chai.js BDD API documentation.Equality
Type Checking
Properties
Strings
Numbers
Arrays & Length
Booleans & Existence
Negation with .not
Negate any assertion using .not:
Chaining Assertions
Chain multiple assertions for better readability:Example: Validate Response Structure
More Assertions
For the complete list of assertions including:- Advanced object and array matchers
- Custom assertions with
.satisfy() - Key checking with
.have.keys() - And many more…
Related Documentation
- Pre-request & Post-response Scripts
- rq.test Object
- rq.response Object
- Tests Documentation
- Chai.js Official Documentation - For complete assertion reference

