Descriptive title used in error messages when no error occurs
The function that should throw an error or reject
Void or Promise
// Synchronous error validation
TestValidator.error("should reject invalid email",
() => validateEmail("invalid-email")
);
// Asynchronous error validation
await TestValidator.error("should reject unauthorized access",
async () => await api.functional.getSecretData()
);
// Validate input validation
TestValidator.error("should throw on empty string",
() => processRequiredInput("")
);
Validates that a function throws an error or rejects when executed.
Expects the provided function to fail. If the function executes successfully without throwing an error or rejecting, this validator will throw an exception. Supports both synchronous and asynchronous functions.