Descriptive title used in error messages
Expected status code(s), can be a single number or array
The function that should throw an HttpError
Void or Promise
// Validate 401 Unauthorized
await TestValidator.httpError("should return 401 for invalid token", 401,
async () => await api.functional.getProtectedResource("invalid-token")
);
// Validate multiple possible error codes
await TestValidator.httpError("should return client error", [400, 404, 422],
async () => await api.functional.updateNonexistentResource(data)
);
// Validate server errors
TestValidator.httpError("should handle server errors", [500, 502, 503],
() => callFaultyEndpoint()
);
Validates that a function throws an HTTP error with specific status codes.
Specialized error validator for HTTP operations. Validates that the function throws an HttpError with one of the specified status codes. Useful for testing API endpoints, authentication, and authorization logic.