-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
/
Copy pathtypes.ts
101 lines (87 loc) · 2.96 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/**
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type {AssertionError} from 'assert';
import type {Config} from '@jest/types';
import type {Expect} from 'expect';
import type CallTracker from './jasmine/CallTracker';
import type Env from './jasmine/Env';
import type JsApiReporter from './jasmine/JsApiReporter';
import type ReportDispatcher from './jasmine/ReportDispatcher';
import type {default as Spec, SpecResult} from './jasmine/Spec';
import type SpyStrategy from './jasmine/SpyStrategy';
import type {default as Suite, SuiteResult} from './jasmine/Suite';
import type Timer from './jasmine/Timer';
import type createSpy from './jasmine/createSpy';
import type SpyRegistry from './jasmine/spyRegistry';
export type SpecDefinitionsFn = () => void;
export interface AssertionErrorWithStack extends AssertionError {
stack: string;
}
// TODO Add expect types to @jest/types or leave it here
// Borrowed from "expect"
// -------START-------
export type SyncExpectationResult = {
pass: boolean;
message: () => string;
};
export type AsyncExpectationResult = Promise<SyncExpectationResult>;
export type ExpectationResult = SyncExpectationResult | AsyncExpectationResult;
export type RawMatcherFn = (
expected: unknown,
actual: unknown,
options?: unknown,
) => ExpectationResult;
// -------END-------
export type RunDetails = {
totalSpecsDefined?: number;
failedExpectations?: SuiteResult['failedExpectations'];
};
export type Reporter = {
jasmineDone: (runDetails: RunDetails) => void;
jasmineStarted: (runDetails: RunDetails) => void;
specDone: (result: SpecResult) => void;
specStarted: (spec: SpecResult) => void;
suiteDone: (result: SuiteResult) => void;
suiteStarted: (result: SuiteResult) => void;
};
export interface Spy extends Record<string, any> {
(this: Record<string, unknown>, ...args: Array<any>): unknown;
and: SpyStrategy;
calls: CallTracker;
restoreObjectToOriginalState?: () => void;
}
type JasmineMatcher = {
(matchersUtil: unknown, context: unknown): JasmineMatcher;
compare: () => RawMatcherFn;
negativeCompare: () => RawMatcherFn;
};
export type JasmineMatchersObject = {[id: string]: JasmineMatcher};
export type Jasmine = {
_DEFAULT_TIMEOUT_INTERVAL: number;
DEFAULT_TIMEOUT_INTERVAL: number;
currentEnv_: ReturnType<typeof Env>['prototype'];
getEnv: () => ReturnType<typeof Env>['prototype'];
createSpy: typeof createSpy;
Env: ReturnType<typeof Env>;
JsApiReporter: typeof JsApiReporter;
ReportDispatcher: typeof ReportDispatcher;
Spec: typeof Spec;
SpyRegistry: typeof SpyRegistry;
Suite: typeof Suite;
Timer: typeof Timer;
version: string;
testPath: Config.Path;
addMatchers: (matchers: JasmineMatchersObject) => void;
} & Expect &
typeof globalThis;
declare global {
namespace NodeJS {
interface Global {
expect: Expect;
}
}
}