@case-contract-testing/case
Version:
Next-generation contract testing suite
62 lines (61 loc) • 2.98 kB
TypeScript
import { type AnyCaseNodeOrData, type CoreAndCombinationMatcher, type AnyCaseMatcher, type AnyData, type HasExample, type LookupableMatcher, type CoreCascadingMatcher, type CoreContextVariableMatcher, type LogLevel, ResolvesTo } from '../../../entities/types';
/**
* Meta matcher that matches all matchers provided. Use this to combine matching rules for the same element
*
* @param matchers - All of the matchers to run against this particular spot
*/
export declare const and: (...matchers: AnyCaseNodeOrData[]) => CoreAndCombinationMatcher;
/**
* Adds an example to the provided matcher. Useful when you have a complicated
* set of constraints and Case can't figure out what the best example should be.
*
* @param matcher - Any matcher
* @param example - The example to use when stripping the matchers
*/
export declare const withExample: <T extends AnyCaseMatcher>(matcher: T, example: AnyData) => HasExample<T>;
/**
* Meta matcher that gives the matcher below it a unique name that can be reused in tests after this one.
*
* @param uniqueName - The name you can use to match this content later
* @param matcherOrData - The content of this named match. If omitted, the content will be looked up in a previously named match
*/
export declare const namedMatch: (uniqueName: string, matcherOrData?: AnyCaseNodeOrData | undefined) => LookupableMatcher;
/**
* Everything inside this matcher will be matched exactly, unless overridden with an `any*` matcher
*
* Use this to switch out of `shapedLike` and back to the default exact matching.
*
* @param content - The example object, array, primitive or matcher to match exactly against
*/
export declare const exactlyLike: (content: AnyCaseNodeOrData) => CoreCascadingMatcher;
/**
* Everything inside this matcher will be matched on the shape of the data (ie, type alone), unless overriden with other matchers
*
* Use this to switch out of the default `exactlyLike` matching.
*
* @param content - The example object, array, primitive or matcher to match against, ignoring content
*/
export declare const shapedLike: (content: AnyCaseNodeOrData) => CoreCascadingMatcher;
/**
* Matches the content of a variable from a provider state.
*
* @param name - The name of the variable
*/
export declare const stateVariable: (name: string) => CoreContextVariableMatcher;
/**
* Matches the content of a variable from a provider state.
*
* @param name - The name of the variable
*/
export declare const stringStateVariable: (name: string) => CoreContextVariableMatcher & ResolvesTo<'string'>;
/**
* Alters the case log level below this matcher. Useful for debugging.
*
* This has no effect on matching.
*
* Note that this log level change is saved into the contract, which may not be what you want.
*
* @param logLevel - The new {@link LogLevel}
* @param child - The next matcher in the tree.
*/
export declare const logLevel: (level: LogLevel, child: AnyCaseNodeOrData) => CoreCascadingMatcher;