@case-contract-testing/case
Version:
Next-generation contract testing suite
48 lines (47 loc) • 2.42 kB
TypeScript
import type { MatchContext } from '../../entities/context/types';
import type { VerifyTriggerReturnObjectError } from '../../entities/errors';
import type { AnyCaseMatcher } from '../../entities/nodes/matchers/types';
import { CaseError, ExecutionError, VerificationError } from './types';
export declare const errorWhen: (test: boolean, err: CaseError | Array<CaseError>) => Array<CaseError>;
/**
* This represents a mismatched matcher
*
* @param matcher - The matcher that generated this error
* @param message - The message that describes this error
* @param actual - The actual value that was recieved
* @param context - The match context this occurred in
* @param expected - An optional expected value (might be a description of what was expected)
* @returns CaseError
*/
export declare const matchingError: (matcher: AnyCaseMatcher, message: string, actual: unknown, context: MatchContext, expected?: unknown) => CaseError;
/**
* This represents a mismatch during a case execution that isn't covered by a
* matcher (usually this is a misconfiguration that is not well described by a
* {@link ../../entities/errors#CaseConfigurationError | CaseConfigurationError})
*
* @param message - The message that describes this error
* @param actual - The actual value that was recieved
* @param code - A code that can be looked up in the documentation
* @param context - The match context this occurred in
* @param expected - An optional expected value (might be a description of what was expected)
* @returns CaseError
*/
export declare const failedExpectationError: (message: string, actual: unknown, code: string, context: MatchContext, expected: unknown) => CaseError;
/**
* This represents an error thrown by user code during execution of an example
* (eg, when a user's trigger is called)
*
* @param error - The error thrown
* @param context - the context that the error was in
* @returns ExecutionError
*/
export declare const executionError: (error: Error, context: MatchContext) => ExecutionError;
/**
* This represents an error thrown during verification using the provided
* verification function
*
* @param error - The VerifyTriggerReturnObjectError from the verification
* @param context - the context that the error was in
* @returns VerificationError
*/
export declare const verificationError: (error: VerifyTriggerReturnObjectError, context: MatchContext) => VerificationError;