import { IFeatureOutcome, IScenarioOutcome, IStepOutcome } from "../Feature/Executor"; import { IFeature, IScenario } from "../Feature/Loader"; import { IRunnerOptions } from "../Options"; import { IStepExpression } from "./Expression"; export type TContext = { variables: { [key: string]: any; }; } & T; type TPromisable = Promise | T; export type TCallbackFuntion = (this: TContext, ...args: any[]) => TPromisable; export type TPattern = string | RegExp; export interface IStepDefinition { pattern: TPattern; options: IStepOptions; cb: TCallbackFuntion; expression: IStepExpression; filePath?: string; } interface IStepOptions { /** in milliseconds */ timeout?: number; } export declare enum StepType { Background = 1, Scenario = 2 } export type TStepKeyword = "given" | "when" | "then" | "and" | "but"; export interface IStep { id: number; type: StepType; keyword: TStepKeyword; name: string; definition: IStepDefinition; nextStepId?: number; } export declare const stepDefinitions: Map; export declare function loadStepDefinitions(options: IRunnerOptions): void; export declare function defineStep(pattern: string, cb: TCallbackFuntion): void; export declare function defineStep(regexp: RegExp, cb: TCallbackFuntion): void; export declare function defineStep(pattern: string, options: IStepOptions, cb?: TCallbackFuntion): void; export declare function defineStep(regexp: RegExp, options: IStepOptions, cb?: TCallbackFuntion): void; export declare function defineStep(firstArg: TPattern, secondArg: IStepOptions | TCallbackFuntion, thirdArg?: TCallbackFuntion): void; export declare function findStepDefinition(step: string): IStepDefinition; export declare const Given: typeof defineStep; export declare const When: typeof defineStep; export declare const Then: typeof defineStep; export declare const And: typeof defineStep; export declare const But: typeof defineStep; /** Hooks */ export declare let beforeFeatureFn: (feature: IFeature) => TPromisable; export declare let afterFeatureFn: (feature: IFeature, outcome: IFeatureOutcome) => TPromisable; export declare function beforeFeature(fn: typeof beforeFeatureFn): void; export declare function afterFeature(fn: typeof afterFeatureFn): void; export declare let beforeScenarioFn: (scenario: IScenario) => TPromisable; export declare let afterScenarioFn: (scenario: IScenario, outcome: IScenarioOutcome) => TPromisable; export declare function beforeScenario(fn: typeof beforeScenarioFn): void; export declare function afterScenario(fn: typeof afterScenarioFn): void; export declare let beforeStepFn: (scenario: IScenario, step: IStep) => TPromisable; export declare let afterStepFn: (scenario: IScenario, step: IStep, outcome: IStepOutcome) => TPromisable; export declare function beforeStep(fn: typeof beforeStepFn): void; export declare function afterStep(fn: typeof afterStepFn): void; export {};