rq object enabling validations, schema checks, and automated workflows.
Common testing approaches include:
- Contract Testing: Validate responses against JSON schemas.
- Unit Testing: Test individual endpoints in isolation.
- Error Handling: Verify API behavior for invalid inputs.

- The Scripts → Pre-request tab enables processing before sending a request, such as setting variable values or modifying headers.
- The Scripts → Post-response tab runs after receiving the response and allows for test assertions, logging, and response validation. This tab includes the Chai.js library, supporting behavior-driven development (BDD) syntax for test assertions.
Scripting Environment
Requestly provides a JavaScript runtime with built-in utilities. Here’s a quick reference table for key methods:| Method/Interface | Description |
|---|---|
rq.test | Define a test with a name and callback for assertions. |
rq.expect | Use Chai.js BDD style assertions to compare values. |
rq.environment | Access and manage environment variables. |
rq.globals | Access and manage global variables. |
rq.response | Access response details (status, body, headers, etc.). |
rq.request | Access request details (method, headers, body, URL, etc.). |
Writing Tests
To create a test, use the following syntax:Example Tests
Status Code Check
JSON Body Validation
Header Check
Schema Validation
Skipping Tests
Response specific assertions
The.to API is supported only for response data in Post-response scripts.
Status code assertions
.to.have assertions
.to.not
All the above assertions can be negated by inserting .not after .to:

