Arrow function containing the operation that should throw an error.
Encapsulates the API operation or business logic that is expected to fail. The function should contain realistic API operations (using IApiOperateStatement within the function body) with invalid data or conditions that trigger appropriate error responses.
Note: The function body can contain IApiOperateStatement calls since this is specifically for testing API error conditions.
General Error Testing Patterns:
HTTP Error Testing Patterns:
Authentication Errors (401):
Authorization Errors (403):
Validation Errors (400, 422):
Not Found Errors (404):
Conflict Errors (409):
Rate Limiting Errors (429):
Server Errors (5xx):
AI function construction: Create realistic error scenarios that test actual business constraints and error handling. Focus on API operation error conditions that should throw errors, including both general exceptions and specific HTTP status code responses.
Descriptive title explaining the error condition being tested.
🚨 CRITICAL: This MUST be a simple string value, NOT an expression! 🚨
❌ WRONG - DO NOT use expressions of any kind:
✅ CORRECT - Use direct string values only:
Should clearly describe what error is expected and why it should occur. This helps understand the negative test case purpose and assists with debugging when expected errors don't occur.
Examples:
General Error Testing:
HTTP Error Testing:
AI title strategy: Focus on the specific error condition and business context that should trigger the failure. Include HTTP status codes when testing API error responses for clarity and debugging assistance.
Type discriminator.
General error validation predicate for TestValidator assertion.
Generates TestValidator.error() call to verify that operations correctly throw errors under specific conditions. Used for testing error handling, business rule violations, and validation of both general errors and HTTP-specific error conditions in API operations.
Preferred over manual error testing: Use this instead of
IIfStatement
with throw statements or try-catch blocks for error validation.E2E testing scenarios:
AI function calling usage: Use when business scenarios should intentionally fail to test error handling, including both general errors and specific HTTP status code validation from API operations.