UNPKG

@contract-case/case-plugin-base

Version:

Plugin framework for writing plugins for the ContractCase test framework

75 lines 3.03 kB
import { AnyCaseMatcher, AnyMockDescriptor, AnyCaseMatcherOrData, AnyData } from '@contract-case/case-plugin-dsl-types'; import type { MatchContext, RunContext, TraversalFns, LogLevelContext, ResultFormatter, DataContext, MatchContextWithoutLookup, ContractLookupFns } from './types'; import { Logger } from '../logger/types'; /** * Folds this case matcher into the context * * @internal * * @param caseNode - any descriptor * @param context - the current context * @returns a context object containing the descriptor combined with the context */ export declare const foldIntoContext: (caseNode: AnyCaseMatcher | AnyMockDescriptor, context: MatchContext) => MatchContext; /** * Constructs a data context object * * @internal * */ export declare const constructDataContext: (makeLogger: (c: LogLevelContext) => Logger, resultPrinter: ResultFormatter, runConfig: Partial<RunContext>, defaults: Record<string, AnyData>, parentVersions: Array<string>) => DataContext; /** * TODO: Move this out of the plugin lib * * @internal */ export declare const constructMatchContext: (traversals: TraversalFns, makeLogger: (c: LogLevelContext) => Logger, makeLookup: (c: MatchContextWithoutLookup) => ContractLookupFns, resultPrinter: ResultFormatter, runConfig: Partial<RunContext>, defaults: Record<string, AnyData>, parentVersions: Array<string>) => MatchContext; /** * TODO: Move this out of the plugin lib * * @internal */ export declare const applyNodeToContext: (caseNodeOrData: AnyCaseMatcherOrData | AnyMockDescriptor, context: MatchContext, runConfig?: Partial<RunContext>) => MatchContext; /** * Adds the current location to the context. Used to determine where we are when * printing logs and errors. * * There are some semantics here: * * Locations are joined together with `.`. For example, calling: * * ``` * addLocation('b', addLocation('a', context)) * ``` * * will result in `"a.b"` being the location at print time. * * If the location is part of an iteration, put it in square brackets, for * example `[2]` or `[keyName]`. This will prevent the location logger from * adding `.` between consecutive locations. For example: * * ``` * addLocation('[1]', addLocation('a', context)) * ``` * * will result in `"a[1]"` being the location at print time. * * If the location starts with `:`, it's only logged during maintainer logs. For * example: * * ``` * addLocation(':internalDetail', addLocation('a', context)) * ``` * * will result in `"a"` during normal and debug logging, but `a:internalDetail` * when maintainer logging (or deeper) is enabled * * @public * * @param location - a string representing the current location. Prefix with `:` * if this location should only be printed during maintainer debugging * @param context - the current {@link MatchContext} * @returns a new {@link MatchContext} with updated location. */ export declare const addLocation: (location: string, context: MatchContext) => MatchContext; //# sourceMappingURL=context.d.ts.map