-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-runner.d.ts
124 lines (124 loc) · 3.69 KB
/
test-runner.d.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
export interface RenderData {
suiteName: string;
type: string;
label: string;
error: Error;
duration: number;
}
interface Render {
verbose: boolean;
suiteName: (opts: Partial<RenderData>) => void;
result: (opts: Partial<RenderData>) => void;
stats: (opts: Partial<RenderData>, prefix?: string) => void;
runAllTitle: ({ whitelist }: {
whitelist: any;
}) => void;
runAllSuiteError: ({ error, name }: {
error: any;
name: any;
}) => void;
runAllStats: (stats: any) => void;
runAllErrorsSummary: ({ errorDetails, invalid }: {
errorDetails: any;
invalid: any;
}) => void;
log: (type: any, str: any) => void;
}
/**
* Simple testing framework. Basic usage:
*
* const suite = new TestRunner('my suite');
* suite.test('truth and nothing but the truth', () => {
* if (false) {
* throw new Error('Gimme some truth!');
* }
* })
* suite.run();
*/
export declare class TestRunner {
label: string;
config: Partial<{
before: Function;
beforeEach: Function;
after: Function;
afterEach: Function;
timeout: number;
skip: boolean;
errorExitOnFirstFail: boolean;
exitOnTimeout: boolean;
}>;
render?: Render;
protected _tests: any[];
protected _wasTimedOut: any[];
constructor(label: string, config?: Partial<{
before: Function;
beforeEach: Function;
after: Function;
afterEach: Function;
timeout: number;
skip: boolean;
errorExitOnFirstFail: boolean;
exitOnTimeout: boolean;
}>, render?: Render);
static skip(message?: string): void;
protected _add(label: string | Function, testFn?: Function, timeout?: number, type?: string): this;
skip(label: string | Function, testFn?: Function, timeout?: number): this;
only(label: string | Function, testFn?: Function, timeout?: number): this;
todo(label: string | Function, testFn?: Function, timeout?: number): this;
test(label: string | Function, testFn?: Function, timeout?: number): this;
/**
* Main run API
*
* @param verbose
* @param context
* @param errorExitOnFirstFail
* @param exitOnTimeout
*/
run(verbose?: boolean, context?: {}, { errorExitOnFirstFail, exitOnTimeout, }?: Partial<{
errorExitOnFirstFail: boolean;
exitOnTimeout: boolean;
}>): Promise<{
ok: number;
errors: number;
skip: number;
todo: number;
duration: number;
details: any[];
errorExitOnFirstFail: boolean;
}>;
protected _run({ index, results, label, testFn, totalToRun }: {
index: any;
results: any;
label: any;
testFn: any;
totalToRun: any;
}, context?: {}): Promise<any>;
protected _execHook(which: any, { label, suite }: {
label: any;
suite: any;
}): Promise<any>;
protected _catch(previousErr: any, fn: Function): Promise<any>;
protected _withTimeout(promise: any, ms: any): Promise<any>;
/**
* Used in TestRunner.runAll to detect test files. Can be customized if needed...
* @type {RegExp}
*/
static testFileRegex: RegExp;
/**
* Will run all tests (see `TestRunner.testFileRegex`) under given directories,
* respecting options
*
* @param dirs
* @param options
*/
static runAll(dirs: string | string[], options?: Partial<{
whitelist: any[];
verbose: boolean;
rootDir: string;
context: object;
errorExitOnFirstFail: boolean;
enableErrorsSummaryOnNonVerbose: boolean;
exitOnTimeout: boolean;
}>): Promise<void>;
}
export {};