1 | interface IAssertionResult<T> {
|
2 | pass: boolean;
|
3 | actual: unknown;
|
4 | expected: T;
|
5 | description: string;
|
6 | operator: string;
|
7 | at?: string;
|
8 | }
|
9 |
|
10 | interface ComparatorAssertionFunction {
|
11 | <T>(actual: unknown, expected: T, description?: string): IAssertionResult<T>;
|
12 | }
|
13 |
|
14 | interface BooleanAssertionFunction {
|
15 | (actual: unknown, description?: string): IAssertionResult<boolean>;
|
16 | }
|
17 |
|
18 | type ErrorAssertionFunction = {
|
19 | (
|
20 | fn: Function,
|
21 | expected: RegExp | Function,
|
22 | description?: string
|
23 | ): IAssertionResult<string | Function>;
|
24 | (fn: Function, description?: string): IAssertionResult<string>;
|
25 | };
|
26 |
|
27 | interface MessageAssertionFunction {
|
28 | (message?: string): IAssertionResult<string>;
|
29 | }
|
30 |
|
31 | interface IAssert$1 {
|
32 | equal: ComparatorAssertionFunction;
|
33 |
|
34 | equals: ComparatorAssertionFunction;
|
35 |
|
36 | eq: ComparatorAssertionFunction;
|
37 |
|
38 | deepEqual: ComparatorAssertionFunction;
|
39 |
|
40 | notEqual: ComparatorAssertionFunction;
|
41 |
|
42 | notEquals: ComparatorAssertionFunction;
|
43 |
|
44 | notEq: ComparatorAssertionFunction;
|
45 |
|
46 | notDeepEqual: ComparatorAssertionFunction;
|
47 |
|
48 | is: ComparatorAssertionFunction;
|
49 |
|
50 | same: ComparatorAssertionFunction;
|
51 |
|
52 | isNot: ComparatorAssertionFunction;
|
53 |
|
54 | notSame: ComparatorAssertionFunction;
|
55 |
|
56 | ok: BooleanAssertionFunction;
|
57 |
|
58 | truthy: BooleanAssertionFunction;
|
59 |
|
60 | notOk: BooleanAssertionFunction;
|
61 |
|
62 | falsy: BooleanAssertionFunction;
|
63 |
|
64 | fail: MessageAssertionFunction;
|
65 |
|
66 | throws: ErrorAssertionFunction;
|
67 | }
|
68 |
|
69 | interface INewTestMessageInput {
|
70 | description: string;
|
71 | skip: boolean;
|
72 | }
|
73 |
|
74 | interface ITestEndMessageInput {
|
75 | description: string;
|
76 | executionTime: number;
|
77 | }
|
78 |
|
79 | interface IMessage<T> {
|
80 | type: string;
|
81 | data: T;
|
82 | }
|
83 |
|
84 | interface INewTestMessage extends IMessage<INewTestMessageInput> {
|
85 | type: 'TEST_START';
|
86 | }
|
87 |
|
88 | interface IAssertionMessage extends IMessage<IAssertionResult<unknown>> {
|
89 | type: 'ASSERTION';
|
90 | }
|
91 |
|
92 | interface ITestEndMessage extends IMessage<ITestEndMessageInput> {
|
93 | type: 'TEST_END';
|
94 | }
|
95 |
|
96 | interface IErrorMessage extends IMessage<{ error: unknown }> {
|
97 | type: 'ERROR';
|
98 | }
|
99 |
|
100 | type Message =
|
101 | | IAssertionMessage
|
102 | | IErrorMessage
|
103 | | ITestEndMessage
|
104 | | INewTestMessage;
|
105 |
|
106 | interface IReporter {
|
107 | (messageStream: AsyncIterable<Message>): Promise<void>;
|
108 | }
|
109 |
|
110 | interface ILogOptions {
|
111 | log?: (message: any) => void;
|
112 | serialize?: (value: any) => string;
|
113 | }
|
114 |
|
115 | declare function createJSONReporter(opts?: ILogOptions): IReporter;
|
116 |
|
117 | declare function createTAPReporter(opts?: ILogOptions): IReporter;
|
118 |
|
119 | interface IReportOptions {
|
120 | reporter: IReporter;
|
121 | }
|
122 |
|
123 | interface IHarnessOptions {
|
124 | onlyMode?: boolean;
|
125 | }
|
126 |
|
127 | interface ITester {
|
128 | test: ITestFunction;
|
129 | skip: ITestFunction;
|
130 | only: ITestFunction;
|
131 | }
|
132 |
|
133 | interface IAssert extends IAssert$1, ITester {}
|
134 |
|
135 | interface ISpecFunction {
|
136 | (assert: IAssert): any;
|
137 | }
|
138 |
|
139 | interface ITestOptions {
|
140 | skip?: boolean;
|
141 | timeout?: number;
|
142 | }
|
143 |
|
144 | interface ITestFunction {
|
145 | (
|
146 | description: string,
|
147 | spec: ISpecFunction,
|
148 | opts?: ITestOptions
|
149 | ): Promise<any> & AsyncIterable<Message>;
|
150 | }
|
151 |
|
152 | interface ITestHarness extends ITester {
|
153 | report(opts: IReportOptions): ReturnType<IReporter>;
|
154 | }
|
155 |
|
156 |
|
157 | declare let Assert: IAssert;
|
158 | declare function hold(): void;
|
159 | declare function report(opts: IReportOptions): ReturnType<IReporter>;
|
160 | declare function createHarness(opts: IHarnessOptions): ITestHarness;
|
161 | declare const test: ITestFunction;
|
162 | declare const only: ITestFunction;
|
163 | declare const skip: ITestFunction;
|
164 |
|
165 | export { Assert, IAssert, IHarnessOptions, ILogOptions, IReportOptions, ISpecFunction, ITestFunction, ITestHarness, ITestOptions, ITester, createHarness, createJSONReporter, createTAPReporter, hold, only, report, skip, test };
|