UNPKG

3.8 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/// <reference types="node" />
8import type { CoverageMapData } from 'istanbul-lib-coverage';
9export declare type ValidTestReturnValues = void | undefined;
10declare type TestReturnValuePromise = Promise<unknown>;
11declare type TestReturnValueGenerator = Generator<void, unknown, void>;
12export declare type TestReturnValue = ValidTestReturnValues | TestReturnValuePromise;
13export declare type TestContext = Record<string, unknown>;
14export declare type DoneFn = (reason?: string | Error) => void;
15export declare type DoneTakingTestFn = (this: TestContext | undefined, done: DoneFn) => ValidTestReturnValues;
16export declare type PromiseReturningTestFn = (this: TestContext | undefined) => TestReturnValue;
17export declare type GeneratorReturningTestFn = (this: TestContext | undefined) => TestReturnValueGenerator;
18export declare type TestName = string;
19export declare type TestFn = PromiseReturningTestFn | GeneratorReturningTestFn | DoneTakingTestFn;
20export declare type ConcurrentTestFn = () => TestReturnValuePromise;
21export declare type BlockFn = () => void;
22export declare type BlockName = string;
23export declare type HookFn = TestFn;
24export declare type Col = unknown;
25export declare type Row = Array<Col>;
26export declare type Table = Array<Row>;
27export declare type ArrayTable = Table | Row;
28export declare type TemplateTable = TemplateStringsArray;
29export declare type TemplateData = Array<unknown>;
30export declare type EachTable = ArrayTable | TemplateTable;
31export declare type TestCallback = BlockFn | TestFn | ConcurrentTestFn;
32export declare type EachTestFn<EachCallback extends TestCallback> = (...args: Array<any>) => ReturnType<EachCallback>;
33declare type Jasmine = {
34 _DEFAULT_TIMEOUT_INTERVAL?: number;
35 addMatchers: (matchers: Record<string, unknown>) => void;
36};
37declare type Each<EachCallback extends TestCallback> = ((table: EachTable, ...taggedTemplateData: Array<unknown>) => (title: string, test: EachTestFn<EachCallback>, timeout?: number) => void) | (() => () => void);
38export interface HookBase {
39 (fn: HookFn, timeout?: number): void;
40}
41export interface ItBase {
42 (testName: TestName, fn: TestFn, timeout?: number): void;
43 each: Each<TestFn>;
44}
45export interface It extends ItBase {
46 only: ItBase;
47 skip: ItBase;
48 todo: (testName: TestName) => void;
49}
50export interface ItConcurrentBase {
51 (testName: string, testFn: ConcurrentTestFn, timeout?: number): void;
52 each: Each<ConcurrentTestFn>;
53}
54export interface ItConcurrentExtended extends ItConcurrentBase {
55 only: ItConcurrentBase;
56 skip: ItConcurrentBase;
57}
58export interface ItConcurrent extends It {
59 concurrent: ItConcurrentExtended;
60}
61export interface DescribeBase {
62 (blockName: BlockName, blockFn: BlockFn): void;
63 each: Each<BlockFn>;
64}
65export interface Describe extends DescribeBase {
66 only: DescribeBase;
67 skip: DescribeBase;
68}
69export interface TestFrameworkGlobals {
70 it: ItConcurrent;
71 test: ItConcurrent;
72 fit: ItBase & {
73 concurrent?: ItConcurrentBase;
74 };
75 xit: ItBase;
76 xtest: ItBase;
77 describe: Describe;
78 xdescribe: DescribeBase;
79 fdescribe: DescribeBase;
80 beforeAll: HookBase;
81 beforeEach: HookBase;
82 afterEach: HookBase;
83 afterAll: HookBase;
84}
85export interface GlobalAdditions extends TestFrameworkGlobals {
86 __coverage__: CoverageMapData;
87 jasmine: Jasmine;
88 fail: () => void;
89 pending: () => void;
90 spyOn: () => void;
91 spyOnProperty: () => void;
92}
93export interface Global extends GlobalAdditions, Omit<NodeJS.Global, keyof GlobalAdditions> {
94 [extras: string]: unknown;
95}
96export {};