forked from hapijs/lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
94 lines (77 loc) · 2.23 KB
/
index.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
export function script(options?: ScriptOptions): Script;
export const assertions: any;
interface Script {
after: After;
afterEach: After;
before: Before;
beforeEach: Before;
describe: Experiment;
experiment: Experiment;
suite: Experiment;
it: Test;
test: Test;
expect(value: any): any;
}
interface Options {
/** number of ms to wait for test/experiment to execute */
timeout?: number;
}
interface Plan {
/** number of assertions expected to execute */
plan?: number;
}
interface OperationFlags {
context: Record<string, any>;
}
interface Operation {
<T>(flags: OperationFlags): Promise<T> | void;
(flags: OperationFlags): void;
}
interface Flags extends OperationFlags {
note(note: string): void;
onCleanup(operation: Operation): void;
onUnhandledRejection(err: Error): void;
onUncaughtException(err: Error): void;
}
interface After {
(operation: Operation): void;
(options: Options, operation: Operation): void;
}
interface Before extends After {}
interface ScriptOptions {
/** should execution of tests be delayed until the CLI runs them */
schedule?: boolean;
cli?: any;
}
interface ExperimentOptions extends Options {
/** skip this experiment */
skip?: boolean;
/** only run this experiment/test */
only?: boolean;
}
interface TestOptionsOnlySkip extends Options, Plan {}
interface TestOptions extends ExperimentOptions, Plan {}
interface TestFunction {
<T>(flags: Flags): Promise<T> | void;
(flags: Flags): void;
}
interface Test {
(title: String, test: TestFunction): void;
(title: String, options: TestOptions, test: TestFunction): void;
/** only execute this test */
only(title: String, test: TestFunction): void;
only(title: String, options: TestOptionsOnlySkip, test: TestFunction): void;
/** skip this test */
skip(title: String, test: TestFunction): void;
skip(title: String, options: TestOptionsOnlySkip, test: TestFunction): void;
}
interface ExperimentFunction {
(title: String, experiment: () => void): void;
(title: String, options: ExperimentOptions, experiment: () => void): void;
}
interface Experiment extends ExperimentFunction {
/** only execute this experiment */
only: ExperimentFunction;
/** skip this experiment */
skip: ExperimentFunction;
}