UNPKG

2.92 kBTypeScriptView Raw
1/**
2 * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 */
8import type { FailedAssertion, Milliseconds, Status } from '@jest/test-result';
9import type { Config } from '@jest/types';
10import ExpectationFailed from '../ExpectationFailed';
11import expectationResultFactory, { Options as ExpectationResultFactoryOptions } from '../expectationResultFactory';
12import type { QueueableFn, default as queueRunner } from '../queueRunner';
13import type { AssertionErrorWithStack } from '../types';
14export declare type Attributes = {
15 id: string;
16 resultCallback: (result: Spec['result']) => void;
17 description: string;
18 throwOnExpectationFailure: unknown;
19 getTestPath: () => Config.Path;
20 queueableFn: QueueableFn;
21 beforeAndAfterFns: () => {
22 befores: Array<QueueableFn>;
23 afters: Array<QueueableFn>;
24 };
25 userContext: () => unknown;
26 onStart: (context: Spec) => void;
27 getSpecName: (spec: Spec) => string;
28 queueRunnerFactory: typeof queueRunner;
29};
30export declare type SpecResult = {
31 id: string;
32 description: string;
33 fullName: string;
34 duration?: Milliseconds;
35 failedExpectations: Array<FailedAssertion>;
36 testPath: Config.Path;
37 passedExpectations: Array<ReturnType<typeof expectationResultFactory>>;
38 pendingReason: string;
39 status: Status;
40 __callsite?: {
41 getColumnNumber: () => number;
42 getLineNumber: () => number;
43 };
44};
45export default class Spec {
46 id: string;
47 description: string;
48 resultCallback: (result: SpecResult) => void;
49 queueableFn: QueueableFn;
50 beforeAndAfterFns: () => {
51 befores: Array<QueueableFn>;
52 afters: Array<QueueableFn>;
53 };
54 userContext: () => unknown;
55 onStart: (spec: Spec) => void;
56 getSpecName: (spec: Spec) => string;
57 queueRunnerFactory: typeof queueRunner;
58 throwOnExpectationFailure: boolean;
59 initError: Error;
60 result: SpecResult;
61 disabled?: boolean;
62 currentRun?: ReturnType<typeof queueRunner>;
63 markedTodo?: boolean;
64 markedPending?: boolean;
65 expand?: boolean;
66 static pendingSpecExceptionMessage: string;
67 static isPendingSpecException(e: Error): boolean;
68 constructor(attrs: Attributes);
69 addExpectationResult(passed: boolean, data: ExpectationResultFactoryOptions, isError?: boolean): void;
70 execute(onComplete?: () => void, enabled?: boolean): void;
71 cancel(): void;
72 onException(error: ExpectationFailed | AssertionErrorWithStack): void;
73 disable(): void;
74 pend(message?: string): void;
75 todo(): void;
76 getResult(): SpecResult;
77 status(enabled?: boolean): "todo" | "passed" | "failed" | "pending" | "disabled";
78 isExecutable(): boolean;
79 getFullName(): string;
80 isAssertionError(error: Error): boolean;
81}