UNPKG

3.07 kBTypeScriptView Raw
1/**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
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 */
7import type { Jest } from '@jest/environment';
8import type { JestExpect } from '@jest/expect';
9import type { Global } from '@jest/types';
10import type { ClassLike, FunctionLike, Mock as JestMock, Mocked as JestMocked, MockedClass as JestMockedClass, MockedFunction as JestMockedFunction, MockedObject as JestMockedObject, Replaced as JestReplaced, Spied as JestSpied, SpiedClass as JestSpiedClass, SpiedFunction as JestSpiedFunction, SpiedGetter as JestSpiedGetter, SpiedSetter as JestSpiedSetter, UnknownFunction } from 'jest-mock';
11export declare const expect: JestExpect;
12export declare const it: Global.GlobalAdditions['it'];
13export declare const test: Global.GlobalAdditions['test'];
14export declare const fit: Global.GlobalAdditions['fit'];
15export declare const xit: Global.GlobalAdditions['xit'];
16export declare const xtest: Global.GlobalAdditions['xtest'];
17export declare const describe: Global.GlobalAdditions['describe'];
18export declare const xdescribe: Global.GlobalAdditions['xdescribe'];
19export declare const fdescribe: Global.GlobalAdditions['fdescribe'];
20export declare const beforeAll: Global.GlobalAdditions['beforeAll'];
21export declare const beforeEach: Global.GlobalAdditions['beforeEach'];
22export declare const afterEach: Global.GlobalAdditions['afterEach'];
23export declare const afterAll: Global.GlobalAdditions['afterAll'];
24declare const jest: Jest;
25declare namespace jest {
26 /**
27 * Constructs the type of a mock function, e.g. the return type of `jest.fn()`.
28 */
29 type Mock<T extends FunctionLike = UnknownFunction> = JestMock<T>;
30 /**
31 * Wraps a class, function or object type with Jest mock type definitions.
32 */
33 type Mocked<T extends object> = JestMocked<T>;
34 /**
35 * Wraps a class type with Jest mock type definitions.
36 */
37 type MockedClass<T extends ClassLike> = JestMockedClass<T>;
38 /**
39 * Wraps a function type with Jest mock type definitions.
40 */
41 type MockedFunction<T extends FunctionLike> = JestMockedFunction<T>;
42 /**
43 * Wraps an object type with Jest mock type definitions.
44 */
45 type MockedObject<T extends object> = JestMockedObject<T>;
46 /**
47 * Constructs the type of a replaced property.
48 */
49 type Replaced<T> = JestReplaced<T>;
50 /**
51 * Constructs the type of a spied class or function.
52 */
53 type Spied<T extends ClassLike | FunctionLike> = JestSpied<T>;
54 /**
55 * Constructs the type of a spied class.
56 */
57 type SpiedClass<T extends ClassLike> = JestSpiedClass<T>;
58 /**
59 * Constructs the type of a spied function.
60 */
61 type SpiedFunction<T extends FunctionLike> = JestSpiedFunction<T>;
62 /**
63 * Constructs the type of a spied getter.
64 */
65 type SpiedGetter<T> = JestSpiedGetter<T>;
66 /**
67 * Constructs the type of a spied setter.
68 */
69 type SpiedSetter<T> = JestSpiedSetter<T>;
70}
71export { jest };