UNPKG

@contract-case/case-core

Version:

Core functionality for the ContractCase contract testing suite

66 lines 3.22 kB
import { HasExample, CoreAndCombinationMatcher, CoreCascadingMatcher, CoreContextVariableMatcher } from '@contract-case/case-entities-internal'; import { MatchContextByExact, LogLevel } from '@contract-case/case-plugin-base'; import { AnyCaseMatcher, AnyCaseMatcherOrData, AnyData, LookupableMatcher, ResolvesTo } from '@contract-case/case-plugin-dsl-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: AnyCaseMatcherOrData[]) => 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<CoreCascadingMatcher>; /** * 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?: AnyCaseMatcherOrData | 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: AnyCaseMatcherOrData) => CoreCascadingMatcher & MatchContextByExact; /** * 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: AnyCaseMatcherOrData) => 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: AnyCaseMatcherOrData) => CoreCascadingMatcher & { "_case:currentRun:context:logLevel": LogLevel; }; //# sourceMappingURL=meta.d.ts.map