Processors Tab
The Processors tab contains advanced features for request automation and validation: scripts that run before and after the request, and assertions that verify the response. These tools are essential for API testing and automation workflows.
Processor Types
The Processors tab contains three sub-tabs:
Runs before the request is sent
Runs after the response is received
Validates response conditions
Pre-Script
Pre-scripts execute JavaScript code before the request is sent. Use them to inspect request data, log information for debugging, or perform pre-flight validation.
Available APIs
| API | Description |
|---|---|
| request.method | HTTP method (GET, POST, etc.) |
| request.url | Full request URL |
| request.headers | Request headers object |
| request.body | Request body as string |
| console.log() | Log messages to script output |
| console.info() | Log info messages |
| console.warn() | Log warning messages |
| console.error() | Log error messages |
| fetch(url, options) | Make HTTP requests (async) |
| setTimeout(fn, ms) | Delay execution |
Example: Log Request Details
// Log request information for debugging
console.log('Method:', request.method);
console.log('URL:', request.url);
console.log('Headers:', JSON.stringify(request.headers, null, 2));
if (request.body) {
console.log('Body:', request.body);
}Example: Validate Request Before Sending
// Check if required headers are present
if (!request.headers['Authorization']) {
console.warn('Warning: No Authorization header set');
}
// Validate JSON body structure
if (request.body) {
try {
const body = JSON.parse(request.body);
if (!body.name) {
console.error('Error: name field is required');
}
} catch (e) {
console.error('Body is not valid JSON');
}
}Post-Script
Post-scripts execute after the response is received. Use them to inspect response data, log results for debugging, or perform custom validation.
Available APIs
| API | Description |
|---|---|
| response.status | HTTP status code (e.g., 200, 404) |
| response.statusText | HTTP status text (e.g., "OK", "Not Found") |
| response.headers | Response headers object |
| response.body | Response body as string |
| response.timing | Timing information object |
| request.* | All request APIs also available |
| console.log() | Log messages to script output |
| fetch(url, options) | Make HTTP requests (async) |
| setTimeout(fn, ms) | Delay execution |
Example: Log Response Details
// Log response information for debugging
console.log('Status:', response.status, response.statusText);
console.log('Headers:', JSON.stringify(response.headers, null, 2));
// Parse JSON body
if (response.body) {
try {
const data = JSON.parse(response.body);
console.log('Response data:', data);
} catch (e) {
console.log('Body (raw):', response.body);
}
}Example: Validate Response Structure
// Validate the response matches expected structure
if (response.status === 200) {
const data = JSON.parse(response.body);
if (!data.id) {
console.error('Missing required field: id');
}
if (!Array.isArray(data.items)) {
console.error('items should be an array');
} else {
console.log('Found', data.items.length, 'items');
}
}Example: Log Timing Information
// Analyze request performance
const timing = response.timing;
console.log('Total time:', timing.total, 'ms');
console.log('DNS lookup:', timing.dns, 'ms');
console.log('TLS handshake:', timing.tls, 'ms');
console.log('Time to first byte:', timing.ttfb, 'ms');JSON.parse(response.body) to convert the response body to a JavaScript object for easier inspection and validation.Script Results
After execution, scripts show their results including:
Execution Duration
The time taken to execute the script is shown in milliseconds. Long-running scripts may indicate inefficient code or infinite loops.
Assertions
Assertions are declarative tests that validate the response. They provide a visual way to define expected conditions without writing code. Each assertion runs automatically after the request completes.
Assertion Structure
Each assertion consists of up to four parts:
| Type | What to check: Status Code, Response Time, Header, JSON Path, or Body |
| Property | For Header and JSON Path types only: the header name or JSONPath expression |
| Operator | How to compare: equals, contains, exists, less than, etc. |
| Expected | The value to compare against (not needed for exists, is empty, etc.) |
Assertion Types
Status Code
Validates the HTTP status code returned by the server.
equalsnot equals><Response Time
Validates the total response time in milliseconds. Useful for performance testing.
<>equalsHeader
Validates response headers. Header name matching is case-insensitive.
equalsnot equalscontainsnot containsexistsnot existsmatches regexJSON Path
Extracts a value from the JSON response body using JSONPath syntax, then validates it. This is the most flexible assertion type with access to all operators.
equalsnot equalscontainsnot contains><existsnot existsis emptyis not emptyis typematches regexJSONPath Syntax Reference
| Path | Description |
|---|---|
| $ | Root object |
| $.property | Top-level property |
| $.user.name | Nested property |
| $.items[0] | First array element (0-indexed) |
| $.items[-1] | Last array element |
| $.items[0:3] | Array slice (elements 0, 1, 2) |
| $.items[*] | All array elements |
| $.items[*].id | Property from all array elements |
| $.items.length | Array length |
| $..name | Recursive search for "name" at any depth |
| $.items[?(@.active)] | Filter: items where active is truthy |
| $.items[?(@.price>100)] | Filter: items where price > 100 |
Body
Validates the entire response body as raw text. Useful for non-JSON responses or full-body matching.
containsnot containsequalsis emptyis not emptymatches regexOperators Reference
Complete list of all comparison operators. Not all operators are available for all assertion types.
| Operator | Description | Expects Value |
|---|---|---|
| equals | Exact match. For JSON, compares normalized structure. | Yes |
| not equals | Passes if values are different. | Yes |
| contains | Substring match. For JSON, supports partial object matching. | Yes |
| not contains | Passes if value is not found. | Yes |
| > (greater than) | Numeric comparison. Both values converted to numbers. | Yes |
| < (less than) | Numeric comparison. Both values converted to numbers. | Yes |
| exists | Passes if value is not undefined or null. | No |
| not exists | Passes if value is undefined or null. | No |
| is empty | Passes if: empty string, empty array [], empty object {}, null, or undefined. | No |
| is not empty | Passes if value has content. | No |
| matches regex | Regular expression match. Supports multiline and cross-platform newlines. | Yes (pattern) |
| is type | Checks JSON type: string, number, boolean, array, object, or null. | Yes (type) |
equals and contains operators normalize JSON before comparison. This means {"a":1} equals { "a": 1 } regardless of whitespace.Assertion Results
After sending a request, each assertion displays its result:
Tab Badge
The Processors tab header shows pass/fail counts as colored badges. A green badge shows passed count, a red badge shows failed count. This provides at-a-glance test status without opening the tab.
Summary Bar
At the bottom of the assertions panel, a summary shows the total count: "Results: X passed, Y failed". This appears only after a request has been sent.
Managing Assertions
Enable/Disable All
The "Enable Assertions" checkbox at the top controls whether assertions run at all. When unchecked, no assertions are evaluated regardless of individual assertion settings. This is useful for temporarily skipping validation during debugging.
Enable/Disable Individual
Each assertion row has its own checkbox. Unchecked assertions are skipped during evaluation but remain in the list. Use this to temporarily disable specific assertions without deleting them.
Add Assertion
Click the "Add" button to create a new assertion. New assertions default to:
- Type: Status Code
- Operator: equals
- Expected: 200
Delete Assertion
Click the trash icon on any assertion row to delete it. This action is immediate and cannot be undone. If you accidentally delete an assertion, you will need to recreate it manually.
Assertion Order
Assertions are evaluated in the order they appear in the list. All enabled assertions run regardless of previous failures (unlike short-circuit evaluation). Results are independent of each other.
Common Testing Patterns
These patterns cover the most common API testing scenarios. Use them as a starting point and customize based on your API's response structure.
GET - Success Response
Basic validation for a successful GET request:
POST - Created Resource
Validation for POST that creates a new resource:
PUT/PATCH - Update Resource
Validation for update operations:
DELETE - Remove Resource
Validation for DELETE operations (varies by API):
Or if the API returns the deleted resource:
GET - List with Pagination
Validation for paginated list endpoints:
POST - Login/Authentication
Validation for authentication endpoints:
400 - Validation Error
Testing that invalid input returns proper errors:
404 - Not Found
Testing behavior when resource doesn't exist:
401 - Unauthorized
Testing authentication requirement:
Performance Testing
Validate response time requirements:
Security Headers Check
Validate security-related response headers: