UNPKG

2.28 kBTypeScriptView Raw
1export function script(options?: ScriptOptions): Script;
2
3export const assertions: any;
4
5interface Script {
6 after: After;
7 afterEach: After;
8 before: Before;
9 beforeEach: Before;
10 describe: Experiment;
11 experiment: Experiment;
12 suite: Experiment;
13 it: Test;
14 test: Test;
15 expect(value: any): any;
16}
17
18interface Options {
19 /** number of ms to wait for test/experiment to execute */
20 timeout?: number;
21}
22
23interface Plan {
24 /** number of assertions expected to execute */
25 plan?: number;
26}
27
28interface OperationFlags {
29 context: Record<string, any>;
30}
31
32interface Operation {
33 <T>(flags: OperationFlags): Promise<T> | void;
34 (flags: OperationFlags): void;
35}
36
37interface Flags extends OperationFlags {
38 note(note: string): void;
39 onCleanup(operation: Operation): void;
40 onUnhandledRejection(err: Error): void;
41 onUncaughtException(err: Error): void;
42}
43
44interface After {
45 (operation: Operation): void;
46 (options: Options, operation: Operation): void;
47}
48
49interface Before extends After {}
50
51interface ScriptOptions {
52 /** should execution of tests be delayed until the CLI runs them */
53 schedule?: boolean;
54 cli?: any;
55}
56
57interface ExperimentOptions extends Options {
58 /** skip this experiment */
59 skip?: boolean;
60 /** only run this experiment/test */
61 only?: boolean;
62}
63
64interface TestOptionsOnlySkip extends Options, Plan {}
65
66interface TestOptions extends ExperimentOptions, Plan {}
67
68interface TestFunction {
69 <T>(flags: Flags): Promise<T> | void;
70 (flags: Flags): void;
71}
72
73interface Test {
74 (title: String, test: TestFunction): void;
75 (title: String, options: TestOptions, test: TestFunction): void;
76 /** only execute this test */
77 only(title: String, test: TestFunction): void;
78 only(title: String, options: TestOptionsOnlySkip, test: TestFunction): void;
79 /** skip this test */
80 skip(title: String, test: TestFunction): void;
81 skip(title: String, options: TestOptionsOnlySkip, test: TestFunction): void;
82}
83
84interface ExperimentFunction {
85 (title: String, experiment: () => void): void;
86 (title: String, options: ExperimentOptions, experiment: () => void): void;
87}
88
89interface Experiment extends ExperimentFunction {
90 /** only execute this experiment */
91 only: ExperimentFunction;
92 /** skip this experiment */
93 skip: ExperimentFunction;
94}