How checks work
Checks validate that your system responds correctly. For example, you might check that:- A POST request returns status 201
- A response body contains expected text
- A response completes within a time limit
To make a failed check abort or fail the entire test, combine checks with Thresholds.
Check for HTTP response code
The most common check validates the HTTP status code:- The value to check (usually the response object)
- An object mapping check names to validation functions
Check for response body content
Sometimes an HTTP 200 response contains an error message. Validate the response body to catch these cases:Check for response body size
You can verify response body size to detect unexpected changes:Multiple checks
You can define multiple checks in a singlecheck() statement:
Check results in output
When your script includes checks, the end-of-test summary displays check statistics:- Individual check results (✓ for pass, ✗ for fail)
- Overall pass rate (100.00%)
- Total passing (✓ 1) and failing (✗ 0) checks
Common check patterns
Checks vs thresholds
If you need the test to fail based on check results, combine checks with thresholds:Check specific operations with tags
Use tags to create thresholds for specific checks:Complete example
Here’s a comprehensive example demonstrating various check patterns:Best practices
Use descriptive names
Make check names clear and specific so failures are easy to understand.
Check meaningful conditions
Validate actual correctness, not just status codes. Check response content too.
Combine with thresholds
Use thresholds to fail tests when check rates drop below acceptable levels.
Keep checks simple
Each check should validate one condition. Use multiple checks for complex validation.