import { EventObject, State, StateNode } from 'xstate'; export interface TestMeta { test?: (testContext: T, state: State) => Promise | void; description?: string | ((state: State) => string); skip?: boolean; } interface TestSegment { state: State; event: EventObject; description: string; test: (testContext: T) => Promise; exec: (testContext: T) => Promise; } interface TestStateResult { error: null | Error; } export interface TestSegmentResult { segment: TestSegment; state: TestStateResult; event: { error: null | Error; }; } export interface TestPath { weight: number; segments: Array>; description: string; /** * Tests and executes each segment in `segments` sequentially, and then * tests the postcondition that the `state` is reached. */ test: (testContext: T) => Promise; } export interface TestPathResult { segments: TestSegmentResult[]; state: TestStateResult; } /** * A collection of `paths` used to verify that the SUT reaches * the target `state`. */ export interface TestPlan { /** * The target state. */ state: State; /** * The paths that reach the target `state`. */ paths: Array>; /** * The description of the target `state` to be reached. */ description: string; /** * Tests the postcondition that the `state` is reached. * * This should be tested after navigating any path in `paths`. */ test: ( /** * The test context used for verifying the SUT. */ testContext: TTestContext) => Promise | void; } /** * A sample event object payload (_without_ the `type` property). * * @example * * ```js * { * value: 'testValue', * other: 'something', * id: 42 * } * ``` */ interface EventCase { type?: never; [prop: string]: any; } export declare type StatePredicate = (state: State) => boolean; /** * Executes an effect using the `testContext` and `event` * that triggers the represented `event`. */ export declare type EventExecutor = ( /** * The testing context used to execute the effect */ testContext: T, /** * The represented event that will be triggered when executed */ event: EventObject) => Promise | void; export interface TestEventConfig { /** * Executes an effect that triggers the represented event. * * @example * * ```js * exec: async (page, event) => { * await page.type('.foo', event.value); * } * ``` */ exec?: EventExecutor; /** * Sample event object payloads _without_ the `type` property. * * @example * * ```js * cases: [ * { value: 'foo' }, * { value: '' } * ] * ``` */ cases?: EventCase[]; } export interface TestEventsConfig { [eventType: string]: EventExecutor | TestEventConfig; } export interface TestModelOptions { events: TestEventsConfig; } export interface TestModelCoverage { stateNodes: Map; transitions: Map>; } export interface CoverageOptions { filter?: (stateNode: StateNode) => boolean; } export {}; //# sourceMappingURL=types.d.ts.map