Assertions that live next to the request
An API test is only useful if it runs every time. In Requestly, tests are part of the request: write them once in the Post-response tab and they execute on every send and every collection run.
Write the assertion
Tests are JavaScript. Assertions use Chaiβs BDD style, so they read close to plain English:
rq.test("Status is 200", () => {
rq.response.to.have.status(200);
});
Reaching into a response body works the same way β parse it, then assert on the fields you care about.
Choose when it runs
The scripting environment has two halves. Pre-request scripts run before the request is sent, which is where you set variables or adjust headers.
Take it past one endpoint
Common patterns include contract testing (validate the response against a JSON schema), unit testing (exercise one endpoint in isolation) and error handling (confirm the API does the right thing with bad input). All three use the same rq object.






