The
rq.test object allows you to write tests in your post-response scripts to validate API responses and ensure your APIs are working as expected. Tests help you automate quality assurance and catch issues early in development.
Properties and Methods
rq.test(name, function)
Creates a test with a given name and a test function. The test function should contain assertions using rq.expect.
Parameters:
name(string): The name of the test (will be displayed in test results)function(function): A function containing test assertions
Writing Tests
Tests are typically written in post-response scripts to validate the API response after it’s received.Basic Test Example
Multiple Assertions in One Test
You can include multiple assertions within a single test:Common Test Patterns
Validate Status Code
Validate Response Structure
Validate Response Time
Conditional Tests
Best Practices
- Use Descriptive Test Names: Make test names clear and specific
- One Concept Per Test: Each test should validate one logical concept
- Test Expected Behavior: Focus on what should happen
- Handle Different Response Codes: Write tests for both success and error scenarios
- Store Values for Later Use: Combine tests with variable storage
Test Results

- ✅ Passed tests (green)
- ❌ Failed tests (red)
- Test execution time
- Assertion details for failed tests

