cypress 3.3.2 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,241 +1,2986 @@
1
- // Type definitions for mocha 2.2.5
2
- // Project: http://mochajs.org/
3
- // Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid>, otiai10 <https://github.com/otiai10>, jt000 <https://github.com/jt000>, Vadim Macagon <https://github.com/enlight>
4
- // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
-
6
- interface MochaSetupOptions {
7
- //milliseconds to wait before considering a test slow
8
- slow?: number;
9
-
10
- // timeout in milliseconds
11
- timeout?: number;
12
-
13
- // ui name "bdd", "tdd", "exports" etc
14
- ui?: string;
15
-
16
- //array of accepted globals
17
- globals?: any[];
18
-
19
- // reporter instance (function or string), defaults to `mocha.reporters.Spec`
20
- reporter?: string | ReporterConstructor;
21
-
22
- // bail on the first test failure
23
- bail?: boolean;
24
-
25
- // ignore global leaks
26
- ignoreLeaks?: boolean;
27
-
28
- // grep string or regexp to filter tests with
29
- grep?: any;
30
-
31
- // require modules before running tests
32
- require?: string[];
33
- }
34
-
35
- declare var mocha: Mocha;
36
- declare var describe: Mocha.IContextDefinition;
37
- declare var xdescribe: Mocha.IContextDefinition;
38
- // alias for `describe`
39
- declare var context: Mocha.IContextDefinition;
40
- // alias for `describe`
41
- declare var suite: Mocha.IContextDefinition;
42
- declare var it: Mocha.ITestDefinition;
43
- declare var xit: Mocha.ITestDefinition;
44
- // alias for `it`
45
- declare var test: Mocha.ITestDefinition;
46
- declare var specify: Mocha.ITestDefinition;
47
-
48
- // Used with the --delay flag; see https://mochajs.org/#hooks
49
- declare function run(): void;
50
-
51
- interface MochaDone {
52
- (error?: any): any;
53
- }
54
-
55
- declare function setup(callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void;
56
- declare function teardown(callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void;
57
- declare function suiteSetup(callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => any): void;
58
- declare function suiteTeardown(callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => any): void;
59
- declare function before(callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => any): void;
60
- declare function before(description: string, callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => any): void;
61
- declare function after(callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => any): void;
62
- declare function after(description: string, callback: (this: Mocha.IHookCallbackContext, done: MochaDone) => any): void;
63
- declare function beforeEach(callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void;
64
- declare function beforeEach(description: string, callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void;
65
- declare function afterEach(callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void;
66
- declare function afterEach(description: string, callback: (this: Mocha.IBeforeAndAfterContext, done: MochaDone) => any): void;
67
-
68
- interface ReporterConstructor {
69
- new(runner: Mocha.IRunner, options: any): any;
70
- }
71
-
72
- declare class Mocha {
73
- currentTest: Mocha.ITestDefinition;
74
- constructor(options?: {
75
- grep?: RegExp;
76
- ui?: string;
77
- reporter?: string | ReporterConstructor;
78
- timeout?: number;
79
- reporterOptions?: any;
80
- slow?: number;
81
- bail?: boolean;
82
- });
83
-
84
- /** Setup mocha with the given options. */
85
- setup(options: MochaSetupOptions): Mocha;
86
- bail(value?: boolean): Mocha;
87
- addFile(file: string): Mocha;
88
- /** Sets reporter by name, defaults to "spec". */
89
- reporter(name: string): Mocha;
90
- /** Sets reporter constructor, defaults to mocha.reporters.Spec. */
91
- reporter(reporter: ReporterConstructor): Mocha;
92
- ui(value: string): Mocha;
93
- grep(value: string): Mocha;
94
- grep(value: RegExp): Mocha;
95
- invert(): Mocha;
96
- ignoreLeaks(value: boolean): Mocha;
97
- checkLeaks(): Mocha;
98
- /**
99
- * Function to allow assertion libraries to throw errors directly into mocha.
100
- * This is useful when running tests in a browser because window.onerror will
101
- * only receive the 'message' attribute of the Error.
102
- */
103
- throwError(error: Error): void;
104
- /** Enables growl support. */
105
- growl(): Mocha;
106
- globals(value: string): Mocha;
107
- globals(values: string[]): Mocha;
108
- useColors(value: boolean): Mocha;
109
- useInlineDiffs(value: boolean): Mocha;
110
- timeout(value: number): Mocha;
111
- slow(value: number): Mocha;
112
- enableTimeouts(value: boolean): Mocha;
113
- asyncOnly(value: boolean): Mocha;
114
- noHighlighting(value: boolean): Mocha;
115
- /** Runs tests and invokes `onComplete()` when finished. */
116
- run(onComplete?: (failures: number) => void): Mocha.IRunner;
117
- }
118
-
119
- // merge the Mocha class declaration with a module
120
- declare namespace Mocha {
121
- interface ISuiteCallbackContext {
122
- timeout(ms: number): this;
123
- retries(n: number): this;
124
- slow(ms: number): this;
125
- }
126
-
127
- interface IHookCallbackContext {
128
- skip(): this;
129
- timeout(ms: number): this;
130
- [index: string]: any;
131
- }
132
-
133
-
134
- interface ITestCallbackContext {
135
- skip(): this;
136
- timeout(ms: number): this;
137
- retries(n: number): this;
138
- slow(ms: number): this;
139
- [index: string]: any;
140
- }
141
-
142
- /** Partial interface for Mocha's `Runnable` class. */
143
- interface IRunnable {
144
- title: string;
145
- fn: Function;
146
- async: boolean;
147
- sync: boolean;
148
- timedOut: boolean;
149
- timeout(n: number): this;
150
- }
151
-
152
- /** Partial interface for Mocha's `Suite` class. */
153
- interface ISuite {
154
- parent: ISuite;
155
- title: string;
156
-
157
- fullTitle(): string;
158
- }
159
-
160
- /** Partial interface for Mocha's `Test` class. */
161
- interface ITest extends IRunnable {
162
- parent: ISuite;
163
- pending: boolean;
164
- state: 'failed' | 'passed' | undefined;
165
-
166
- fullTitle(): string;
167
- }
168
-
169
- interface IBeforeAndAfterContext extends IHookCallbackContext {
170
- currentTest: ITest;
171
- }
172
-
173
-
174
- /** Partial interface for Mocha's `Runner` class. */
175
- interface IRunner { }
176
-
177
- interface IContextDefinition {
178
- (description: string, callback: (this: ISuiteCallbackContext) => void): ISuite;
179
- only(description: string, callback: (this: ISuiteCallbackContext) => void): ISuite;
180
- skip(description: string, callback: (this: ISuiteCallbackContext) => void): void;
181
- timeout(ms: number): void;
182
- }
183
-
184
- interface ITestDefinition {
185
- (expectation: string, callback?: (this: ITestCallbackContext, done: MochaDone) => any): ITest;
186
- only(expectation: string, callback?: (this: ITestCallbackContext, done: MochaDone) => any): ITest;
187
- skip(expectation: string, callback?: (this: ITestCallbackContext, done: MochaDone) => any): void;
188
- timeout(ms: number): void;
189
- state: "failed" | "passed";
190
- }
191
-
192
- export module reporters {
193
- export class Base {
194
- stats: {
195
- suites: number;
196
- tests: number;
197
- passes: number;
198
- pending: number;
199
- failures: number;
200
- };
201
-
202
- constructor(runner: IRunner);
203
- }
204
-
205
- export class Doc extends Base { }
206
- export class Dot extends Base { }
207
- export class HTML extends Base { }
208
- export class HTMLCov extends Base { }
209
- export class JSON extends Base { }
210
- export class JSONCov extends Base { }
211
- export class JSONStream extends Base { }
212
- export class Landing extends Base { }
213
- export class List extends Base { }
214
- export class Markdown extends Base { }
215
- export class Min extends Base { }
216
- export class Nyan extends Base { }
217
- export class Progress extends Base {
218
- /**
219
- * @param options.open String used to indicate the start of the progress bar.
220
- * @param options.complete String used to indicate a complete test on the progress bar.
221
- * @param options.incomplete String used to indicate an incomplete test on the progress bar.
222
- * @param options.close String used to indicate the end of the progress bar.
223
- */
224
- constructor(runner: IRunner, options?: {
225
- open?: string;
226
- complete?: string;
227
- incomplete?: string;
228
- close?: string;
229
- });
230
- }
231
- export class Spec extends Base { }
232
- export class TAP extends Base { }
233
- export class XUnit extends Base {
234
- constructor(runner: IRunner, options?: any);
235
- }
236
- }
237
- }
238
-
239
- declare module "mocha" {
240
- export = Mocha;
241
- }
1
+ // Type definitions for mocha 5.2
2
+ // Project: https://mochajs.org
3
+ // Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid>
4
+ // otiai10 <https://github.com/otiai10>
5
+ // jt000 <https://github.com/jt000>
6
+ // Vadim Macagon <https://github.com/enlight>
7
+ // Andrew Bradley <https://github.com/cspotcode>
8
+ // Dmitrii Sorin <https://github.com/1999>
9
+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
10
+ // TypeScript Version: 2.1
11
+
12
+ /**
13
+ * Mocha API
14
+ *
15
+ * @see https://mochajs.org/api/mocha
16
+ */
17
+ declare class Mocha {
18
+ private _growl;
19
+ private _reporter;
20
+ private _ui;
21
+
22
+ constructor(options?: Mocha.MochaOptions);
23
+
24
+ suite: Mocha.Suite;
25
+ files: string[];
26
+ options: Mocha.MochaInstanceOptions;
27
+
28
+ /**
29
+ * Enable or disable bailing on the first failure.
30
+ *
31
+ * @see https://mochajs.org/api/mocha#bail
32
+ */
33
+ bail(bail?: boolean): this;
34
+
35
+ /**
36
+ * Add test `file`.
37
+ *
38
+ * @see https://mochajs.org/api/mocha#addFile
39
+ */
40
+ addFile(file: string): this;
41
+
42
+ /**
43
+ * Set reporter to one of the built-in reporters.
44
+ *
45
+ * @see https://mochajs.org/api/mocha#reporter
46
+ */
47
+ reporter(reporter: Mocha.Reporter, reporterOptions?: any): this;
48
+
49
+ /**
50
+ * Set reporter to the provided constructor, one of the built-in reporters, or loads a reporter
51
+ * from a module path. Defaults to `"spec"`.
52
+ *
53
+ * @see https://mochajs.org/api/mocha#reporter
54
+ */
55
+ reporter(reporter?: string | Mocha.ReporterConstructor, reporterOptions?: any): this;
56
+
57
+ /**
58
+ * Set test UI to one of the built-in test interfaces.
59
+ *
60
+ * @see https://mochajs.org/api/mocha#ui
61
+ */
62
+ ui(name: Mocha.Interface): this;
63
+
64
+ /**
65
+ * Set test UI to one of the built-in test interfaces or loads a test interface from a module
66
+ * path. Defaults to `"bdd"`.
67
+ *
68
+ * @see https://mochajs.org/api/mocha#ui
69
+ */
70
+ ui(name?: string): this;
71
+
72
+ /**
73
+ * Escape string and add it to grep as a RegExp.
74
+ *
75
+ * @see https://mochajs.org/api/mocha#fgrep
76
+ */
77
+ fgrep(str: string): this;
78
+
79
+ /**
80
+ * Add regexp to grep, if `re` is a string it is escaped.
81
+ *
82
+ * @see https://mochajs.org/api/mocha#grep
83
+ */
84
+ grep(re: string | RegExp): this;
85
+
86
+ /**
87
+ * Invert `.grep()` matches.
88
+ *
89
+ * @see https://mochajs.org/api/mocha#invert
90
+ */
91
+ invert(): this;
92
+
93
+ /**
94
+ * Ignore global leaks.
95
+ *
96
+ * @see https://mochajs.org/api/mocha#ignoreLeaks
97
+ */
98
+ ignoreLeaks(ignore: boolean): this;
99
+
100
+ /**
101
+ * Enable global leak checking.
102
+ *
103
+ * @see https://mochajs.org/api/mocha#checkLeaks
104
+ */
105
+ checkLeaks(): this;
106
+
107
+ /**
108
+ * Display long stack-trace on failing
109
+ *
110
+ * @see https://mochajs.org/api/mocha#fullTrace
111
+ */
112
+ fullTrace(): this;
113
+
114
+ /**
115
+ * Enable growl support.
116
+ *
117
+ * @see https://mochajs.org/api/mocha#growl
118
+ */
119
+ growl(): this;
120
+
121
+ /**
122
+ * Ignore `globals` array or string.
123
+ *
124
+ * @see https://mochajs.org/api/mocha#globals
125
+ */
126
+ globals(globals: string | ReadonlyArray<string>): this;
127
+
128
+ /**
129
+ * Emit color output.
130
+ *
131
+ * @see https://mochajs.org/api/mocha#useColors
132
+ */
133
+ useColors(colors: boolean): this;
134
+
135
+ /**
136
+ * Use inline diffs rather than +/-.
137
+ *
138
+ * @see https://mochajs.org/api/mocha#useInlineDiffs
139
+ */
140
+ useInlineDiffs(inlineDiffs: boolean): this;
141
+
142
+ /**
143
+ * Do not show diffs at all.
144
+ *
145
+ * @see https://mochajs.org/api/mocha#hideDiff
146
+ */
147
+ hideDiff(hideDiff: boolean): this;
148
+
149
+ /**
150
+ * Set the timeout in milliseconds.
151
+ *
152
+ * @see https://mochajs.org/api/mocha#timeout
153
+ */
154
+ timeout(timeout: string | number): this;
155
+
156
+ /**
157
+ * Set the number of times to retry failed tests.
158
+ *
159
+ * @see https://mochajs.org/api/mocha#retries
160
+ */
161
+ retries(n: number): this;
162
+
163
+ /**
164
+ * Set slowness threshold in milliseconds.
165
+ *
166
+ * @see https://mochajs.org/api/mocha#slow
167
+ */
168
+ slow(slow: string | number): this;
169
+
170
+ /**
171
+ * Enable timeouts.
172
+ *
173
+ * @see https://mochajs.org/api/mocha#enableTimeouts
174
+ */
175
+ enableTimeouts(enabled?: boolean): this;
176
+
177
+ /**
178
+ * Makes all tests async (accepting a callback)
179
+ *
180
+ * @see https://mochajs.org/api/mocha#asyncOnly.
181
+ */
182
+ asyncOnly(): this;
183
+
184
+ /**
185
+ * Disable syntax highlighting (in browser).
186
+ *
187
+ * @see https://mochajs.org/api/mocha#noHighlighting
188
+ */
189
+ noHighlighting(): this;
190
+
191
+ /**
192
+ * Enable uncaught errors to propagate (in browser).
193
+ *
194
+ * @see https://mochajs.org/api/mocha#allowUncaught
195
+ */
196
+ allowUncaught(): boolean;
197
+
198
+ /**
199
+ * Delay root suite execution.
200
+ *
201
+ * @see https://mochajs.org/api/mocha#delay
202
+ */
203
+ delay(): boolean;
204
+
205
+ /**
206
+ * Tests marked only fail the suite
207
+ *
208
+ * @see https://mochajs.org/api/mocha#forbidOnly
209
+ */
210
+ forbidOnly(): boolean;
211
+
212
+ /**
213
+ * Pending tests and tests marked skip fail the suite
214
+ *
215
+ * @see https://mochajs.org/api/mocha#forbidPending
216
+ */
217
+ forbidPending(): boolean;
218
+
219
+ /**
220
+ * Run tests and invoke `fn()` when complete.
221
+ *
222
+ * Note that `run` relies on Node's `require` to execute
223
+ * the test interface functions and will be subject to the
224
+ * cache - if the files are already in the `require` cache,
225
+ * they will effectively be skipped. Therefore, to run tests
226
+ * multiple times or to run tests in files that are already
227
+ * in the `require` cache, make sure to clear them from the
228
+ * cache first in whichever manner best suits your needs.
229
+ *
230
+ * @see https://mochajs.org/api/mocha#run
231
+ */
232
+ run(fn?: (failures: number) => void): Mocha.Runner;
233
+
234
+ /**
235
+ * Load registered files.
236
+ *
237
+ * @see https://mochajs.org/api/mocha#loadFiles
238
+ */
239
+ protected loadFiles(fn?: () => void): void;
240
+ }
241
+
242
+ declare namespace Mocha {
243
+ namespace utils {
244
+ /**
245
+ * Compute a slug from the given `str`.
246
+ *
247
+ * @see https://mochajs.org/api/module-utils.html#.slug
248
+ */
249
+ function slug(str: string): string;
250
+
251
+ /**
252
+ * Strip the function definition from `str`, and re-indent for pre whitespace.
253
+ *
254
+ * @see https://mochajs.org/api/module-utils.html#.clean
255
+ */
256
+ function clean(str: string): string;
257
+
258
+ /**
259
+ * Highlight the given string of `js`.
260
+ */
261
+ function highlight(js: string): string;
262
+
263
+ /**
264
+ * Takes some variable and asks `Object.prototype.toString()` what it thinks it is.
265
+ */
266
+ function type(value: any): string;
267
+
268
+ /**
269
+ * Stringify `value`. Different behavior depending on type of value:
270
+ *
271
+ * - If `value` is undefined or null, return `'[undefined]'` or `'[null]'`, respectively.
272
+ * - If `value` is not an object, function or array, return result of `value.toString()` wrapped in double-quotes.
273
+ * - If `value` is an *empty* object, function, or array, returns `'{}'`, `'[Function]'`, or `'[]'` respectively.
274
+ * - If `value` has properties, call canonicalize} on it, then return result of `JSON.stringify()`
275
+ *
276
+ * @see https://mochajs.org/api/module-utils.html#.stringify
277
+ */
278
+ function stringify(value: any): string;
279
+
280
+ /**
281
+ * Return a new Thing that has the keys in sorted order. Recursive.
282
+ *
283
+ * If the Thing...
284
+ * - has already been seen, return string `'[Circular]'`
285
+ * - is `undefined`, return string `'[undefined]'`
286
+ * - is `null`, return value `null`
287
+ * - is some other primitive, return the value
288
+ * - is not a primitive or an `Array`, `Object`, or `Function`, return the value of the Thing's `toString()` method
289
+ * - is a non-empty `Array`, `Object`, or `Function`, return the result of calling this function again.
290
+ * - is an empty `Array`, `Object`, or `Function`, returns `'[]'`, `'{}'`, or `'[Function]'` respectively.
291
+ *
292
+ * @see https://mochajs.org/api/module-utils.html#.canonicalize
293
+ */
294
+ function canonicalize(value: any, stack: any[], typeHint: string): any;
295
+
296
+ /**
297
+ * Lookup file names at the given `path`.
298
+ *
299
+ * @see https://mochajs.org/api/Mocha.utils.html#.exports.lookupFiles
300
+ */
301
+ function lookupFiles(filepath: string, extensions?: string[], recursive?: boolean): string[];
302
+
303
+ /**
304
+ * Generate an undefined error with a message warning the user.
305
+ *
306
+ * @see https://mochajs.org/api/module-utils.html#.undefinedError
307
+ */
308
+ function undefinedError(): Error;
309
+
310
+ /**
311
+ * Generate an undefined error if `err` is not defined.
312
+ *
313
+ * @see https://mochajs.org/api/module-utils.html#.getError
314
+ */
315
+ function getError(err: Error | undefined): Error;
316
+
317
+ /**
318
+ * When invoking this function you get a filter function that get the Error.stack as an
319
+ * input, and return a prettify output. (i.e: strip Mocha and internal node functions from
320
+ * stack trace).
321
+ *
322
+ * @see https://mochajs.org/api/module-utils.html#.stackTraceFilter
323
+ */
324
+ function stackTraceFilter(): (stack: string) => string;
325
+ }
326
+
327
+ namespace interfaces {
328
+ function bdd(suite: Suite): void;
329
+ function tdd(suite: Suite): void;
330
+ function qunit(suite: Suite): void;
331
+ function exports(suite: Suite): void;
332
+ }
333
+
334
+ // #region Test interface augmentations
335
+
336
+ interface HookFunction {
337
+ /**
338
+ * [bdd, qunit, tdd] Describe a "hook" to execute the given callback `fn`. The name of the
339
+ * function is used as the name of the hook.
340
+ *
341
+ * - _Only available when invoked via the mocha CLI._
342
+ */
343
+ (fn: Func): void;
344
+
345
+ /**
346
+ * [bdd, qunit, tdd] Describe a "hook" to execute the given callback `fn`. The name of the
347
+ * function is used as the name of the hook.
348
+ *
349
+ * - _Only available when invoked via the mocha CLI._
350
+ */
351
+ (fn: AsyncFunc): void;
352
+
353
+ /**
354
+ * [bdd, qunit, tdd] Describe a "hook" to execute the given `title` and callback `fn`.
355
+ *
356
+ * - _Only available when invoked via the mocha CLI._
357
+ */
358
+ (name: string, fn?: Func): void;
359
+
360
+ /**
361
+ * [bdd, qunit, tdd] Describe a "hook" to execute the given `title` and callback `fn`.
362
+ *
363
+ * - _Only available when invoked via the mocha CLI._
364
+ */
365
+ (name: string, fn?: AsyncFunc): void;
366
+ }
367
+
368
+ interface SuiteFunction {
369
+ /**
370
+ * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing
371
+ * nested suites.
372
+ *
373
+ * - _Only available when invoked via the mocha CLI._
374
+ */
375
+ (title: string, fn: (this: Suite) => void): Suite;
376
+
377
+ /**
378
+ * [qunit] Describe a "suite" with the given `title`.
379
+ *
380
+ * - _Only available when invoked via the mocha CLI._
381
+ */
382
+ (title: string): Suite;
383
+
384
+ /**
385
+ * [bdd, tdd, qunit] Indicates this suite should be executed exclusively.
386
+ *
387
+ * - _Only available when invoked via the mocha CLI._
388
+ */
389
+ only: ExclusiveSuiteFunction;
390
+
391
+ /**
392
+ * [bdd, tdd] Indicates this suite should not be executed.
393
+ *
394
+ * - _Only available when invoked via the mocha CLI._
395
+ */
396
+ skip: PendingSuiteFunction;
397
+ }
398
+
399
+ interface ExclusiveSuiteFunction {
400
+ /**
401
+ * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing
402
+ * nested suites. Indicates this suite should be executed exclusively.
403
+ *
404
+ * - _Only available when invoked via the mocha CLI._
405
+ */
406
+ (title: string, fn: (this: Suite) => void): Suite;
407
+
408
+ /**
409
+ * [qunit] Describe a "suite" with the given `title`. Indicates this suite should be executed
410
+ * exclusively.
411
+ *
412
+ * - _Only available when invoked via the mocha CLI._
413
+ */
414
+ (title: string): Suite;
415
+ }
416
+
417
+ /**
418
+ * [bdd, tdd] Describe a "suite" with the given `title` and callback `fn` containing
419
+ * nested suites. Indicates this suite should not be executed.
420
+ *
421
+ * - _Only available when invoked via the mocha CLI._
422
+ *
423
+ * @returns [bdd] `Suite`
424
+ * @returns [tdd] `void`
425
+ */
426
+ interface PendingSuiteFunction {
427
+ (title: string, fn: (this: Suite) => void): Suite | void;
428
+ }
429
+
430
+ interface TestFunction {
431
+ /**
432
+ * Describe a specification or test-case with the given callback `fn` acting as a thunk.
433
+ * The name of the function is used as the name of the test.
434
+ *
435
+ * - _Only available when invoked via the mocha CLI._
436
+ */
437
+ (fn: Func): Test;
438
+
439
+ /**
440
+ * Describe a specification or test-case with the given callback `fn` acting as a thunk.
441
+ * The name of the function is used as the name of the test.
442
+ *
443
+ * - _Only available when invoked via the mocha CLI._
444
+ */
445
+ (fn: AsyncFunc): Test;
446
+
447
+ /**
448
+ * Describe a specification or test-case with the given `title` and callback `fn` acting
449
+ * as a thunk.
450
+ *
451
+ * - _Only available when invoked via the mocha CLI._
452
+ */
453
+ (title: string, fn?: Func): Test;
454
+
455
+ /**
456
+ * Describe a specification or test-case with the given `title` and callback `fn` acting
457
+ * as a thunk.
458
+ *
459
+ * - _Only available when invoked via the mocha CLI._
460
+ */
461
+ (title: string, fn?: AsyncFunc): Test;
462
+
463
+ /**
464
+ * Indicates this test should be executed exclusively.
465
+ *
466
+ * - _Only available when invoked via the mocha CLI._
467
+ */
468
+ only: ExclusiveTestFunction;
469
+
470
+ /**
471
+ * Indicates this test should not be executed.
472
+ *
473
+ * - _Only available when invoked via the mocha CLI._
474
+ */
475
+ skip: PendingTestFunction;
476
+
477
+ /**
478
+ * Number of attempts to retry.
479
+ *
480
+ * - _Only available when invoked via the mocha CLI._
481
+ */
482
+ retries(n: number): void;
483
+ }
484
+
485
+ interface ExclusiveTestFunction {
486
+ /**
487
+ * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn`
488
+ * acting as a thunk. The name of the function is used as the name of the test. Indicates
489
+ * this test should be executed exclusively.
490
+ *
491
+ * - _Only available when invoked via the mocha CLI._
492
+ */
493
+ (fn: Func): Test;
494
+
495
+ /**
496
+ * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn`
497
+ * acting as a thunk. The name of the function is used as the name of the test. Indicates
498
+ * this test should be executed exclusively.
499
+ *
500
+ * - _Only available when invoked via the mocha CLI._
501
+ */
502
+ (fn: AsyncFunc): Test;
503
+
504
+ /**
505
+ * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and
506
+ * callback `fn` acting as a thunk. Indicates this test should be executed exclusively.
507
+ *
508
+ * - _Only available when invoked via the mocha CLI._
509
+ */
510
+ (title: string, fn?: Func): Test;
511
+
512
+ /**
513
+ * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and
514
+ * callback `fn` acting as a thunk. Indicates this test should be executed exclusively.
515
+ *
516
+ * - _Only available when invoked via the mocha CLI._
517
+ */
518
+ (title: string, fn?: AsyncFunc): Test;
519
+ }
520
+
521
+ interface PendingTestFunction {
522
+ /**
523
+ * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn`
524
+ * acting as a thunk. The name of the function is used as the name of the test. Indicates
525
+ * this test should not be executed.
526
+ *
527
+ * - _Only available when invoked via the mocha CLI._
528
+ */
529
+ (fn: Func): Test;
530
+
531
+ /**
532
+ * [bdd, tdd, qunit] Describe a specification or test-case with the given callback `fn`
533
+ * acting as a thunk. The name of the function is used as the name of the test. Indicates
534
+ * this test should not be executed.
535
+ *
536
+ * - _Only available when invoked via the mocha CLI._
537
+ */
538
+ (fn: AsyncFunc): Test;
539
+
540
+ /**
541
+ * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and
542
+ * callback `fn` acting as a thunk. Indicates this test should not be executed.
543
+ *
544
+ * - _Only available when invoked via the mocha CLI._
545
+ */
546
+ (title: string, fn?: Func): Test;
547
+
548
+ /**
549
+ * [bdd, tdd, qunit] Describe a specification or test-case with the given `title` and
550
+ * callback `fn` acting as a thunk. Indicates this test should not be executed.
551
+ *
552
+ * - _Only available when invoked via the mocha CLI._
553
+ */
554
+ (title: string, fn?: AsyncFunc): Test;
555
+ }
556
+
557
+ /**
558
+ * Execute after each test case.
559
+ *
560
+ * - _Only available when invoked via the mocha CLI._
561
+ *
562
+ * @see https://mochajs.org/api/global.html#afterEach
563
+ */
564
+ let afterEach: HookFunction;
565
+
566
+ /**
567
+ * Execute after running tests.
568
+ *
569
+ * - _Only available when invoked via the mocha CLI._
570
+ *
571
+ * @see https://mochajs.org/api/global.html#after
572
+ */
573
+ let after: HookFunction;
574
+
575
+ /**
576
+ * Execute before each test case.
577
+ *
578
+ * - _Only available when invoked via the mocha CLI._
579
+ *
580
+ * @see https://mochajs.org/api/global.html#beforeEach
581
+ */
582
+ let beforeEach: HookFunction;
583
+
584
+ /**
585
+ * Execute before running tests.
586
+ *
587
+ * - _Only available when invoked via the mocha CLI._
588
+ *
589
+ * @see https://mochajs.org/api/global.html#before
590
+ */
591
+ let before: HookFunction;
592
+
593
+ /**
594
+ * Describe a "suite" containing nested suites and tests.
595
+ *
596
+ * - _Only available when invoked via the mocha CLI._
597
+ */
598
+ let describe: SuiteFunction;
599
+
600
+ /**
601
+ * Describes a test case.
602
+ *
603
+ * - _Only available when invoked via the mocha CLI._
604
+ */
605
+ let it: TestFunction;
606
+
607
+ /**
608
+ * Describes a pending test case.
609
+ *
610
+ * - _Only available when invoked via the mocha CLI._
611
+ */
612
+ let xit: PendingTestFunction;
613
+
614
+ /**
615
+ * Execute before each test case.
616
+ *
617
+ * - _Only available when invoked via the mocha CLI._
618
+ *
619
+ * @see https://mochajs.org/api/global.html#beforeEach
620
+ */
621
+ let setup: HookFunction;
622
+
623
+ /**
624
+ * Execute before running tests.
625
+ *
626
+ * - _Only available when invoked via the mocha CLI._
627
+ *
628
+ * @see https://mochajs.org/api/global.html#before
629
+ */
630
+ let suiteSetup: HookFunction;
631
+
632
+ /**
633
+ * Execute after running tests.
634
+ *
635
+ * - _Only available when invoked via the mocha CLI._
636
+ *
637
+ * @see https://mochajs.org/api/global.html#after
638
+ */
639
+ let suiteTeardown: HookFunction;
640
+
641
+ /**
642
+ * Describe a "suite" containing nested suites and tests.
643
+ *
644
+ * - _Only available when invoked via the mocha CLI._
645
+ */
646
+ let suite: SuiteFunction;
647
+
648
+ /**
649
+ * Execute after each test case.
650
+ *
651
+ * - _Only available when invoked via the mocha CLI._
652
+ *
653
+ * @see https://mochajs.org/api/global.html#afterEach
654
+ */
655
+ let teardown: HookFunction;
656
+
657
+ /**
658
+ * Describes a test case.
659
+ *
660
+ * - _Only available when invoked via the mocha CLI._
661
+ */
662
+ let test: TestFunction;
663
+
664
+ /**
665
+ * Triggers root suite execution.
666
+ *
667
+ * - _Only available if flag --delay is passed into Mocha._
668
+ * - _Only available when invoked via the mocha CLI._
669
+ *
670
+ * @see https://mochajs.org/api/global.html#runWithSuite
671
+ */
672
+ function run(): void;
673
+
674
+ // #endregion Test interface augmentations
675
+
676
+ namespace reporters {
677
+ /**
678
+ * Initialize a new `Base` reporter.
679
+ *
680
+ * All other reporters generally inherit from this reporter, providing stats such as test duration,
681
+ * number of tests passed / failed, etc.
682
+ *
683
+ * @see https://mochajs.org/api/Mocha.reporters.Base.html
684
+ */
685
+ class Base {
686
+ constructor(runner: Runner, options?: MochaOptions);
687
+ /** @deprecated Use the overload that accepts `Mocha.Runner` instead. */
688
+ constructor(runner: IRunner, options?: MochaOptions);
689
+
690
+ /**
691
+ * Test run statistics
692
+ */
693
+ stats: Stats;
694
+
695
+ /**
696
+ * Test failures
697
+ */
698
+ failures: Test[];
699
+
700
+ /**
701
+ * The configured runner
702
+ */
703
+ runner: Runner;
704
+
705
+ /**
706
+ * Output common epilogue used by many of the bundled reporters.
707
+ *
708
+ * @see https://mochajs.org/api/Mocha.reporters.Base.html#.Base#epilogue
709
+ */
710
+ epilogue(): void;
711
+
712
+ done?(failures: number, fn?: (failures: number) => void): void;
713
+ }
714
+
715
+ namespace Base {
716
+ /**
717
+ * Enables coloring by default
718
+ *
719
+ * @see https://mochajs.org/api/module-base#.useColors
720
+ */
721
+ let useColors: boolean;
722
+
723
+ /**
724
+ * Inline diffs instead of +/-
725
+ *
726
+ * @see https://mochajs.org/api/module-base#.inlineDiffs
727
+ */
728
+ let inlineDiffs: boolean;
729
+
730
+ /**
731
+ * Default color map
732
+ *
733
+ * @see https://mochajs.org/api/module-base#.colors
734
+ */
735
+ const colors: ColorMap;
736
+
737
+ /**
738
+ * Default color map
739
+ *
740
+ * @see https://mochajs.org/api/module-base#.colors
741
+ */
742
+ interface ColorMap {
743
+ // added by Base
744
+ pass: number;
745
+ fail: number;
746
+ "bright pass": number;
747
+ "bright fail": number;
748
+ "bright yellow": number;
749
+ pending: number;
750
+ suite: number;
751
+ "error title": number;
752
+ "error message": number;
753
+ "error stack": number;
754
+ checkmark: number;
755
+ fast: number;
756
+ medium: number;
757
+ slow: number;
758
+ green: number;
759
+ light: number;
760
+ "diff gutter": number;
761
+ "diff added": number;
762
+ "diff removed": number;
763
+
764
+ // added by Progress
765
+ progress: number;
766
+
767
+ // added by Landing
768
+ plane: number;
769
+ "plane crash": number;
770
+ runway: number;
771
+
772
+ [key: string]: number;
773
+ }
774
+
775
+ /**
776
+ * Default symbol map
777
+ *
778
+ * @see https://mochajs.org/api/module-base#.symbols
779
+ */
780
+ const symbols: SymbolMap;
781
+
782
+ /**
783
+ * Default symbol map
784
+ *
785
+ * @see https://mochajs.org/api/module-base#.symbols
786
+ */
787
+ interface SymbolMap {
788
+ ok: string;
789
+ err: string;
790
+ dot: string;
791
+ comma: string;
792
+ bang: string;
793
+ [key: string]: string;
794
+ }
795
+
796
+ /**
797
+ * Color `str` with the given `type` (from `colors`)
798
+ *
799
+ * @see https://mochajs.org/api/module-base#.color
800
+ */
801
+ function color(type: string, str: string): string;
802
+
803
+ /**
804
+ * Expose terminal window size
805
+ *
806
+ * @see https://mochajs.org/api/module-base#.window
807
+ */
808
+ const window: {
809
+ width: number;
810
+ };
811
+
812
+ /**
813
+ * ANSI TTY control sequences common among reporters.
814
+ *
815
+ * @see https://mochajs.org/api/module-base#.cursor
816
+ */
817
+ namespace cursor {
818
+ /**
819
+ * Hides the cursor
820
+ */
821
+ function hide(): void;
822
+
823
+ /**
824
+ * Shows the cursor
825
+ */
826
+ function show(): void;
827
+
828
+ /**
829
+ * Deletes the current line
830
+ */
831
+ function deleteLine(): void;
832
+
833
+ /**
834
+ * Moves to the beginning of the line
835
+ */
836
+ function beginningOfLine(): void;
837
+
838
+ /**
839
+ * Clears the line and moves to the beginning of the line.
840
+ */
841
+ function CR(): void;
842
+ }
843
+
844
+ /**
845
+ * Returns a diff between two strings with colored ANSI output.
846
+ *
847
+ * @see https://mochajs.org/api/module-base#.generateDiff
848
+ */
849
+ function generateDiff(actual: string, expected: string): string;
850
+
851
+ /**
852
+ * Output the given `failures` as a list.
853
+ *
854
+ * @see https://mochajs.org/api/Mocha.reporters.Base.html#.exports.list1
855
+ */
856
+ function list(failures: Test[]): void;
857
+ }
858
+
859
+ /**
860
+ * Initialize a new `Dot` matrix test reporter.
861
+ *
862
+ * @see https://mochajs.org/api/Mocha.reporters.Dot.html
863
+ */
864
+ class Dot extends Base {
865
+ }
866
+
867
+ /**
868
+ * Initialize a new `Doc` reporter.
869
+ *
870
+ * @see https://mochajs.org/api/Mocha.reporters.Doc.html
871
+ */
872
+ class Doc extends Base {
873
+ }
874
+
875
+ /**
876
+ * Initialize a new `TAP` test reporter.
877
+ *
878
+ * @see https://mochajs.org/api/Mocha.reporters.TAP.html
879
+ */
880
+ class TAP extends Base {
881
+ }
882
+
883
+ /**
884
+ * Initialize a new `JSON` reporter
885
+ *
886
+ * @see https://mochajs.org/api/Mocha.reporters.JSON.html
887
+ */
888
+ class JSON extends Base {
889
+ }
890
+
891
+ /**
892
+ * Initialize a new `HTML` reporter.
893
+ *
894
+ * - _This reporter cannot be used on the console._
895
+ *
896
+ * @see https://mochajs.org/api/Mocha.reporters.HTML.html
897
+ */
898
+ class HTML extends Base {
899
+ /**
900
+ * Provide suite URL.
901
+ *
902
+ * @see https://mochajs.org/api/Mocha.reporters.HTML.html#suiteURL
903
+ */
904
+ suiteURL(suite: Suite): string;
905
+
906
+ /**
907
+ * Provide test URL.
908
+ *
909
+ * @see https://mochajs.org/api/Mocha.reporters.HTML.html#testURL
910
+ */
911
+ testURL(test: Test): string;
912
+
913
+ /**
914
+ * Adds code toggle functionality for the provided test's list element.
915
+ *
916
+ * @see https://mochajs.org/api/Mocha.reporters.HTML.html#addCodeToggle
917
+ */
918
+ addCodeToggle(el: HTMLLIElement, contents: string): void;
919
+ }
920
+
921
+ /**
922
+ * Initialize a new `List` test reporter.
923
+ *
924
+ * @see https://mochajs.org/api/Mocha.reporters.List.html
925
+ */
926
+ class List extends Base {
927
+ }
928
+
929
+ /**
930
+ * Initialize a new `Min` minimal test reporter (best used with --watch).
931
+ *
932
+ * @see https://mochajs.org/api/Mocha.reporters.Min.html
933
+ */
934
+ class Min extends Base {
935
+ }
936
+
937
+ /**
938
+ * Initialize a new `Spec` test reporter.
939
+ *
940
+ * @see https://mochajs.org/api/Mocha.reporters.Spec.html
941
+ */
942
+ class Spec extends Base {
943
+ }
944
+
945
+ /**
946
+ * Initialize a new `NyanCat` test reporter.
947
+ *
948
+ * @see https://mochajs.org/api/Mocha.reporters.Nyan.html
949
+ */
950
+ class Nyan extends Base {
951
+ private colorIndex;
952
+ private numberOfLines;
953
+ private rainbowColors;
954
+ private scoreboardWidth;
955
+ private tick;
956
+ private trajectories;
957
+ private trajectoryWidthMax;
958
+ private draw;
959
+ private drawScoreboard;
960
+ private appendRainbow;
961
+ private drawRainbow;
962
+ private drawNyanCat;
963
+ private face;
964
+ private cursorUp;
965
+ private cursorDown;
966
+ private generateColors;
967
+ private rainbowify;
968
+ }
969
+
970
+ /**
971
+ * Initialize a new `XUnit` test reporter.
972
+ *
973
+ * @see https://mochajs.org/api/Mocha.reporters.XUnit.html
974
+ */
975
+ class XUnit extends Base {
976
+ constructor(runner: Runner, options?: XUnit.MochaOptions);
977
+ /** @deprecated Use the overload that accepts `Mocha.Runner` instead. */
978
+ constructor(runner: IRunner, options?: XUnit.MochaOptions);
979
+
980
+ /**
981
+ * Override done to close the stream (if it's a file).
982
+ *
983
+ * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#done
984
+ */
985
+ done(failures: number, fn: (failures: number) => void): void;
986
+
987
+ /**
988
+ * Write out the given line.
989
+ *
990
+ * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#write
991
+ */
992
+ write(line: string): void;
993
+
994
+ /**
995
+ * Output tag for the given `test.`
996
+ *
997
+ * @see https://mochajs.org/api/Mocha.reporters.XUnit.html#test
998
+ */
999
+ test(test: Test): void;
1000
+ }
1001
+
1002
+ namespace XUnit {
1003
+ interface MochaOptions extends Mocha.MochaOptions {
1004
+ reporterOptions?: ReporterOptions;
1005
+ }
1006
+
1007
+ interface ReporterOptions {
1008
+ output?: string;
1009
+ suiteName?: string;
1010
+ }
1011
+ }
1012
+
1013
+ /**
1014
+ * Initialize a new `Markdown` test reporter.
1015
+ *
1016
+ * @see https://mochajs.org/api/Mocha.reporters.Markdown.html
1017
+ */
1018
+ class Markdown extends Base {
1019
+ }
1020
+
1021
+ /**
1022
+ * Initialize a new `Progress` bar test reporter.
1023
+ *
1024
+ * @see https://mochajs.org/api/Mocha.reporters.Progress.html
1025
+ */
1026
+ class Progress extends Base {
1027
+ constructor(runner: Runner, options?: Progress.MochaOptions);
1028
+ /** @deprecated Use the overload that accepts `Mocha.Runner` instead. */
1029
+ constructor(runner: IRunner, options?: Progress.MochaOptions);
1030
+ }
1031
+
1032
+ namespace Progress {
1033
+ interface MochaOptions extends Mocha.MochaOptions {
1034
+ reporterOptions?: ReporterOptions;
1035
+ }
1036
+
1037
+ interface ReporterOptions {
1038
+ open?: string;
1039
+ complete?: string;
1040
+ incomplete?: string;
1041
+ close?: string;
1042
+ verbose?: boolean;
1043
+ }
1044
+ }
1045
+
1046
+ /**
1047
+ * Initialize a new `Landing` reporter.
1048
+ *
1049
+ * @see https://mochajs.org/api/Mocha.reporters.Landing.html
1050
+ */
1051
+ class Landing extends Base {
1052
+ }
1053
+
1054
+ /**
1055
+ * Initialize a new `JSONStream` test reporter.
1056
+ *
1057
+ * @see https://mochajs.org/api/Mocha.reporters.JSONStream.html
1058
+ */
1059
+ class JSONStream extends Base {
1060
+ }
1061
+
1062
+ // value-only aliases
1063
+ const base: typeof Base;
1064
+ const dot: typeof Dot;
1065
+ const doc: typeof Doc;
1066
+ const tap: typeof TAP;
1067
+ const json: typeof JSON;
1068
+ const html: typeof HTML;
1069
+ const list: typeof List;
1070
+ const spec: typeof Spec;
1071
+ const nyan: typeof Nyan;
1072
+ const xunit: typeof XUnit;
1073
+ const markdown: typeof Markdown;
1074
+ const progress: typeof Progress;
1075
+ const landing: typeof Landing;
1076
+ // NOTE: not possible to type this correctly:
1077
+ // const "json-stream": typeof JSONStream;
1078
+ }
1079
+
1080
+ /**
1081
+ * Initialize a new `Runnable` with the given `title` and callback `fn`.
1082
+ *
1083
+ * @see https://mochajs.org/api/Runnable.html
1084
+ */
1085
+ class Runnable {
1086
+ private _slow;
1087
+ private _enableTimeouts;
1088
+ private _retries;
1089
+ private _currentRetry;
1090
+ private _timeout;
1091
+ private _timeoutError;
1092
+
1093
+ constructor(title: string, fn?: Func | AsyncFunc);
1094
+
1095
+ title: string;
1096
+ fn: Func | AsyncFunc | undefined;
1097
+ body: string;
1098
+ async: boolean;
1099
+ sync: boolean;
1100
+ timedOut: boolean;
1101
+ pending: boolean;
1102
+ duration?: number;
1103
+ parent?: Suite;
1104
+ state?: "failed" | "passed";
1105
+ timer?: any;
1106
+ ctx?: Context;
1107
+ callback?: Done;
1108
+ allowUncaught?: boolean;
1109
+ file?: string;
1110
+
1111
+ /**
1112
+ * Get test timeout.
1113
+ *
1114
+ * @see https://mochajs.org/api/Runnable.html#timeout
1115
+ */
1116
+ timeout(): number;
1117
+
1118
+ /**
1119
+ * Set test timeout.
1120
+ *
1121
+ * @see https://mochajs.org/api/Runnable.html#timeout
1122
+ */
1123
+ timeout(ms: string | number): this;
1124
+
1125
+ /**
1126
+ * Get test slowness threshold.
1127
+ *
1128
+ * @see https://mochajs.org/api/Runnable.html#slow
1129
+ */
1130
+ slow(): number;
1131
+
1132
+ /**
1133
+ * Set test slowness threshold.
1134
+ *
1135
+ * @see https://mochajs.org/api/Runnable.html#slow
1136
+ */
1137
+ slow(ms: string | number): this;
1138
+
1139
+ /**
1140
+ * Get whether timeouts are enabled.
1141
+ *
1142
+ * @see https://mochajs.org/api/Runnable.html#enableTimeouts
1143
+ */
1144
+ enableTimeouts(): boolean;
1145
+
1146
+ /**
1147
+ * Set whether timeouts are enabled.
1148
+ *
1149
+ * @see https://mochajs.org/api/Runnable.html#enableTimeouts
1150
+ */
1151
+ enableTimeouts(enabled: boolean): this;
1152
+
1153
+ /**
1154
+ * Halt and mark as pending.
1155
+ */
1156
+ skip(): never;
1157
+
1158
+ /**
1159
+ * Check if this runnable or its parent suite is marked as pending.
1160
+ *
1161
+ * @see https://mochajs.org/api/Runnable.html#isPending
1162
+ */
1163
+ isPending(): boolean;
1164
+
1165
+ /**
1166
+ * Return `true` if this Runnable has failed.
1167
+ */
1168
+ isFailed(): boolean;
1169
+
1170
+ /**
1171
+ * Return `true` if this Runnable has passed.
1172
+ */
1173
+ isPassed(): boolean;
1174
+
1175
+ /**
1176
+ * Set or get number of retries.
1177
+ *
1178
+ * @see https://mochajs.org/api/Runnable.html#retries
1179
+ */
1180
+ retries(): number;
1181
+
1182
+ /**
1183
+ * Set or get number of retries.
1184
+ *
1185
+ * @see https://mochajs.org/api/Runnable.html#retries
1186
+ */
1187
+ retries(n: number): void;
1188
+
1189
+ /**
1190
+ * Set or get current retry
1191
+ *
1192
+ * @see https://mochajs.org/api/Runnable.html#currentRetry
1193
+ */
1194
+ protected currentRetry(): number;
1195
+
1196
+ /**
1197
+ * Set or get current retry
1198
+ *
1199
+ * @see https://mochajs.org/api/Runnable.html#currentRetry
1200
+ */
1201
+ protected currentRetry(n: number): void;
1202
+
1203
+ /**
1204
+ * Return the full title generated by recursively concatenating the parent's full title.
1205
+ */
1206
+ fullTitle(): string;
1207
+
1208
+ /**
1209
+ * Return the title path generated by concatenating the parent's title path with the title.
1210
+ */
1211
+ titlePath(): string[];
1212
+
1213
+ /**
1214
+ * Clear the timeout.
1215
+ *
1216
+ * @see https://mochajs.org/api/Runnable.html#clearTimeout
1217
+ */
1218
+ clearTimeout(): void;
1219
+
1220
+ /**
1221
+ * Inspect the runnable void of private properties.
1222
+ *
1223
+ * @see https://mochajs.org/api/Runnable.html#inspect
1224
+ */
1225
+ inspect(): string;
1226
+
1227
+ /**
1228
+ * Reset the timeout.
1229
+ *
1230
+ * @see https://mochajs.org/api/Runnable.html#resetTimeout
1231
+ */
1232
+ resetTimeout(): void;
1233
+
1234
+ /**
1235
+ * Get a list of whitelisted globals for this test run.
1236
+ *
1237
+ * @see https://mochajs.org/api/Runnable.html#globals
1238
+ */
1239
+ globals(): string[];
1240
+
1241
+ /**
1242
+ * Set a list of whitelisted globals for this test run.
1243
+ *
1244
+ * @see https://mochajs.org/api/Runnable.html#globals
1245
+ */
1246
+ globals(globals: ReadonlyArray<string>): void;
1247
+
1248
+ /**
1249
+ * Run the test and invoke `fn(err)`.
1250
+ *
1251
+ * @see https://mochajs.org/api/Runnable.html#run
1252
+ */
1253
+ run(fn: Done): void;
1254
+ }
1255
+
1256
+ // #region Runnable "error" event
1257
+ interface Runnable extends NodeJS.EventEmitter {
1258
+ on(event: "error", listener: (error: any) => void): this;
1259
+ once(event: "error", listener: (error: any) => void): this;
1260
+ addListener(event: "error", listener: (error: any) => void): this;
1261
+ removeListener(event: "error", listener: (error: any) => void): this;
1262
+ prependListener(event: "error", listener: (error: any) => void): this;
1263
+ prependOnceListener(event: "error", listener: (error: any) => void): this;
1264
+ emit(name: "error", error: any): boolean;
1265
+ }
1266
+ // #endregion Runnable "error" event
1267
+ // #region Runnable untyped events
1268
+ interface Runnable extends NodeJS.EventEmitter {
1269
+ on(event: string, listener: (...args: any[]) => void): this;
1270
+ once(event: string, listener: (...args: any[]) => void): this;
1271
+ addListener(event: string, listener: (...args: any[]) => void): this;
1272
+ removeListener(event: string, listener: (...args: any[]) => void): this;
1273
+ prependListener(event: string, listener: (...args: any[]) => void): this;
1274
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
1275
+ emit(name: string, ...args: any[]): boolean;
1276
+ }
1277
+ // #endregion Runnable untyped events
1278
+
1279
+ /**
1280
+ * Test context
1281
+ *
1282
+ * @see https://mochajs.org/api/module-Context.html#~Context
1283
+ */
1284
+ class Context {
1285
+ private _runnable;
1286
+
1287
+ test?: Runnable;
1288
+ currentTest?: Test;
1289
+
1290
+ /**
1291
+ * Get the context `Runnable`.
1292
+ */
1293
+ runnable(): Runnable;
1294
+
1295
+ /**
1296
+ * Set the context `Runnable`.
1297
+ */
1298
+ runnable(runnable: Runnable): this;
1299
+ /** @deprecated Use the overload that accepts `Mocha.Runnable` instead. */
1300
+ runnable(runnable: IRunnable): this;
1301
+
1302
+ /**
1303
+ * Get test timeout.
1304
+ */
1305
+ timeout(): number;
1306
+
1307
+ /**
1308
+ * Set test timeout.
1309
+ */
1310
+ timeout(ms: string | number): this;
1311
+
1312
+ /**
1313
+ * Get whether timeouts are enabled.
1314
+ */
1315
+ enableTimeouts(): boolean;
1316
+
1317
+ /**
1318
+ * Set whether timeouts are enabled.
1319
+ */
1320
+ enableTimeouts(enabled: boolean): this;
1321
+
1322
+ /**
1323
+ * Get test slowness threshold.
1324
+ */
1325
+ slow(): number;
1326
+
1327
+ /**
1328
+ * Set test slowness threshold.
1329
+ */
1330
+ slow(ms: string | number): this;
1331
+
1332
+ /**
1333
+ * Mark a test as skipped.
1334
+ */
1335
+ skip(): never;
1336
+
1337
+ /**
1338
+ * Get the number of allowed retries on failed tests.
1339
+ */
1340
+ retries(): number;
1341
+
1342
+ /**
1343
+ * Set the number of allowed retries on failed tests.
1344
+ */
1345
+ retries(n: number): this;
1346
+
1347
+ [key: string]: any;
1348
+ }
1349
+
1350
+ /**
1351
+ * Initialize a `Runner` for the given `suite`.
1352
+ *
1353
+ * @see https://mochajs.org/api/Mocha.Runner.html
1354
+ */
1355
+ class Runner {
1356
+ private _globals;
1357
+ private _abort;
1358
+ private _delay;
1359
+ private _defaultGrep;
1360
+ private next;
1361
+ private hookErr;
1362
+ private prevGlobalsLength;
1363
+ private nextSuite;
1364
+
1365
+ constructor(suite: Suite, delay: boolean);
1366
+
1367
+ /** @deprecated Use the overload that accepts `Mocha.Suite` instead. */
1368
+ constructor(suite: ISuite, delay: boolean);
1369
+
1370
+ suite: Suite;
1371
+ started: boolean;
1372
+ total: number;
1373
+ failures: number;
1374
+ asyncOnly?: boolean;
1375
+ allowUncaught?: boolean;
1376
+ fullStackTrace?: boolean;
1377
+ forbidOnly?: boolean;
1378
+ forbidPending?: boolean;
1379
+ ignoreLeaks?: boolean;
1380
+ test?: Test;
1381
+ currentRunnable?: Runnable;
1382
+ stats?: Stats; // added by reporters
1383
+
1384
+ /**
1385
+ * Run tests with full titles matching `re`. Updates runner.total
1386
+ * with number of tests matched.
1387
+ *
1388
+ * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#grep
1389
+ */
1390
+ grep(re: RegExp, invert: boolean): this;
1391
+
1392
+ /**
1393
+ * Returns the number of tests matching the grep search for the
1394
+ * given suite.
1395
+ *
1396
+ * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#grepTotal
1397
+ */
1398
+ grepTotal(suite: Suite): number;
1399
+
1400
+ /** @deprecated Use the overload that accepts `Mocha.Suite` instead. */
1401
+ grepTotal(suite: ISuite): number;
1402
+
1403
+ /**
1404
+ * Gets the allowed globals.
1405
+ *
1406
+ * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#globals
1407
+ */
1408
+ globals(): string[];
1409
+
1410
+ /**
1411
+ * Allow the given `arr` of globals.
1412
+ *
1413
+ * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#globals
1414
+ */
1415
+ globals(arr: ReadonlyArray<string>): this;
1416
+
1417
+ /**
1418
+ * Run the root suite and invoke `fn(failures)` on completion.
1419
+ *
1420
+ * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#run
1421
+ */
1422
+ run(fn?: (failures: number) => void): this;
1423
+
1424
+ /**
1425
+ * Cleanly abort execution.
1426
+ *
1427
+ * @see https://mochajs.org/api/Mocha.Runner.html#.Runner#abort
1428
+ */
1429
+ abort(): this;
1430
+
1431
+ /**
1432
+ * Handle uncaught exceptions.
1433
+ *
1434
+ * @see https://mochajs.org/api/Mocha.Runner.html#uncaught
1435
+ */
1436
+ uncaught(err: any): void;
1437
+
1438
+ /**
1439
+ * Wrapper for setImmediate, process.nextTick, or browser polyfill.
1440
+ */
1441
+ protected static immediately(callback: Function): void;
1442
+
1443
+ /**
1444
+ * Return a list of global properties.
1445
+ *
1446
+ * @see https://mochajs.org/api/Mocha.Runner.html#globalProps
1447
+ */
1448
+ protected globalProps(): string[];
1449
+
1450
+ /**
1451
+ * Check for global variable leaks.
1452
+ *
1453
+ * @see https://mochajs.org/api/Mocha.Runner.html#checkGlobals
1454
+ */
1455
+ protected checkGlobals(test: Test): void;
1456
+
1457
+ /**
1458
+ * Fail the given `test`.
1459
+ *
1460
+ * @see https://mochajs.org/api/Mocha.Runner.html#fail
1461
+ */
1462
+ protected fail(test: Test, err: any): void;
1463
+
1464
+ /**
1465
+ * Fail the given `hook` with `err`.
1466
+ *
1467
+ * Hook failures work in the following pattern:
1468
+ * - If bail, then exit
1469
+ * - Failed `before` hook skips all tests in a suite and subsuites,
1470
+ * but jumps to corresponding `after` hook
1471
+ * - Failed `before each` hook skips remaining tests in a
1472
+ * suite and jumps to corresponding `after each` hook,
1473
+ * which is run only once
1474
+ * - Failed `after` hook does not alter
1475
+ * execution order
1476
+ * - Failed `after each` hook skips remaining tests in a
1477
+ * suite and subsuites, but executes other `after each`
1478
+ * hooks
1479
+ *
1480
+ * @see https://mochajs.org/api/Mocha.Runner.html#failHook
1481
+ */
1482
+ protected failHook(hook: Hook, err: any): void;
1483
+
1484
+ /**
1485
+ * Run hook `name` callbacks and then invoke `fn()`.
1486
+ *
1487
+ * @see https://mochajs.org/api/Mocha.Runner.html#hook
1488
+ */
1489
+ protected hook(name: string, fn: () => void): void;
1490
+
1491
+ /**
1492
+ * Run hook `name` for the given array of `suites`
1493
+ * in order, and callback `fn(err, errSuite)`.
1494
+ *
1495
+ * @see https://mochajs.org/api/Mocha.Runner.html#hooks
1496
+ */
1497
+ protected hooks(name: string, suites: Suite[], fn: (err?: any, errSuite?: Suite) => void): void;
1498
+
1499
+ /**
1500
+ * Run hooks from the top level down.
1501
+ *
1502
+ * @see https://mochajs.org/api/Mocha.Runner.html#hookUp
1503
+ */
1504
+ protected hookUp(name: string, fn: (err?: any, errSuite?: Suite) => void): void;
1505
+
1506
+ /**
1507
+ * Run hooks from the bottom up.
1508
+ *
1509
+ * @see https://mochajs.org/api/Mocha.Runner.html#hookDown
1510
+ */
1511
+ protected hookDown(name: string, fn: (err?: any, errSuite?: Suite) => void): void;
1512
+
1513
+ /**
1514
+ * Return an array of parent Suites from closest to furthest.
1515
+ *
1516
+ * @see https://mochajs.org/api/Mocha.Runner.html#parents
1517
+ */
1518
+ protected parents(): Suite[];
1519
+
1520
+ /**
1521
+ * Run the current test and callback `fn(err)`.
1522
+ *
1523
+ * @see https://mochajs.org/api/Mocha.Runner.html#runTest
1524
+ */
1525
+ protected runTest(fn: Done): any;
1526
+
1527
+ /**
1528
+ * Run tests in the given `suite` and invoke the callback `fn()` when complete.
1529
+ *
1530
+ * @see https://mochajs.org/api/Mocha.Runner.html#runTests
1531
+ */
1532
+ protected runTests(suite: Suite, fn: (errSuite?: Suite) => void): void;
1533
+
1534
+ /**
1535
+ * Run the given `suite` and invoke the callback `fn()` when complete.
1536
+ *
1537
+ * @see https://mochajs.org/api/Mocha.Runner.html#runSuite
1538
+ */
1539
+ protected runSuite(suite: Suite, fn: (errSuite?: Suite) => void): void;
1540
+ }
1541
+
1542
+ // #region Runner "waiting" event
1543
+ interface Runner {
1544
+ on(event: "waiting", listener: (rootSuite: Suite) => void): this;
1545
+ once(event: "waiting", listener: (rootSuite: Suite) => void): this;
1546
+ addListener(event: "waiting", listener: (rootSuite: Suite) => void): this;
1547
+ removeListener(event: "waiting", listener: (rootSuite: Suite) => void): this;
1548
+ prependListener(event: "waiting", listener: (rootSuite: Suite) => void): this;
1549
+ prependOnceListener(event: "waiting", listener: (rootSuite: Suite) => void): this;
1550
+ emit(name: "waiting", rootSuite: Suite): boolean;
1551
+ }
1552
+ // #endregion Runner "waiting" event
1553
+ // #region Runner "start" event
1554
+ interface Runner extends NodeJS.EventEmitter {
1555
+ on(event: "start", listener: () => void): this;
1556
+ once(event: "start", listener: () => void): this;
1557
+ addListener(event: "start", listener: () => void): this;
1558
+ removeListener(event: "start", listener: () => void): this;
1559
+ prependListener(event: "start", listener: () => void): this;
1560
+ prependOnceListener(event: "start", listener: () => void): this;
1561
+ emit(name: "start"): boolean;
1562
+ }
1563
+ // #endregion Runner "start" event
1564
+ // #region Runner "end" event
1565
+ interface Runner extends NodeJS.EventEmitter {
1566
+ on(event: "end", listener: () => void): this;
1567
+ once(event: "end", listener: () => void): this;
1568
+ addListener(event: "end", listener: () => void): this;
1569
+ removeListener(event: "end", listener: () => void): this;
1570
+ prependListener(event: "end", listener: () => void): this;
1571
+ prependOnceListener(event: "end", listener: () => void): this;
1572
+ emit(name: "end"): boolean;
1573
+ }
1574
+ // #endregion Runner "end" event
1575
+ // #region Runner "suite" event
1576
+ interface Runner extends NodeJS.EventEmitter {
1577
+ on(event: "suite", listener: (suite: Suite) => void): this;
1578
+ once(event: "suite", listener: (suite: Suite) => void): this;
1579
+ addListener(event: "suite", listener: (suite: Suite) => void): this;
1580
+ removeListener(event: "suite", listener: (suite: Suite) => void): this;
1581
+ prependListener(event: "suite", listener: (suite: Suite) => void): this;
1582
+ prependOnceListener(event: "suite", listener: (suite: Suite) => void): this;
1583
+ emit(name: "suite", suite: Suite): boolean;
1584
+ }
1585
+ // #endregion Runner "suite" event
1586
+ // #region Runner "suite end" event
1587
+ interface Runner extends NodeJS.EventEmitter {
1588
+ on(event: "suite end", listener: (suite: Suite) => void): this;
1589
+ once(event: "suite end", listener: (suite: Suite) => void): this;
1590
+ addListener(event: "suite end", listener: (suite: Suite) => void): this;
1591
+ removeListener(event: "suite end", listener: (suite: Suite) => void): this;
1592
+ prependListener(event: "suite end", listener: (suite: Suite) => void): this;
1593
+ prependOnceListener(event: "suite end", listener: (suite: Suite) => void): this;
1594
+ emit(name: "suite end", suite: Suite): boolean;
1595
+ }
1596
+ // #endregion Runner "suite end" event
1597
+ // #region Runner "test" event
1598
+ interface Runner extends NodeJS.EventEmitter {
1599
+ on(event: "test", listener: (test: Test) => void): this;
1600
+ once(event: "test", listener: (test: Test) => void): this;
1601
+ addListener(event: "test", listener: (test: Test) => void): this;
1602
+ removeListener(event: "test", listener: (test: Test) => void): this;
1603
+ prependListener(event: "test", listener: (test: Test) => void): this;
1604
+ prependOnceListener(event: "test", listener: (test: Test) => void): this;
1605
+ emit(name: "test", test: Test): boolean;
1606
+ }
1607
+ // #endregion Runner "test" event
1608
+ // #region Runner "test end" event
1609
+ interface Runner extends NodeJS.EventEmitter {
1610
+ on(event: "test end", listener: (test: Test) => void): this;
1611
+ once(event: "test end", listener: (test: Test) => void): this;
1612
+ addListener(event: "test end", listener: (test: Test) => void): this;
1613
+ removeListener(event: "test end", listener: (test: Test) => void): this;
1614
+ prependListener(event: "test end", listener: (test: Test) => void): this;
1615
+ prependOnceListener(event: "test end", listener: (test: Test) => void): this;
1616
+ emit(name: "test end", test: Test): boolean;
1617
+ }
1618
+ // #endregion Runner "test end" event
1619
+ // #region Runner "hook" event
1620
+ interface Runner extends NodeJS.EventEmitter {
1621
+ on(event: "hook", listener: (hook: Hook) => void): this;
1622
+ once(event: "hook", listener: (hook: Hook) => void): this;
1623
+ addListener(event: "hook", listener: (hook: Hook) => void): this;
1624
+ removeListener(event: "hook", listener: (hook: Hook) => void): this;
1625
+ prependListener(event: "hook", listener: (hook: Hook) => void): this;
1626
+ prependOnceListener(event: "hook", listener: (hook: Hook) => void): this;
1627
+ emit(name: "hook", hook: Hook): boolean;
1628
+ }
1629
+ // #endregion Runner "hook" event
1630
+ // #region Runner "hook end" event
1631
+ interface Runner extends NodeJS.EventEmitter {
1632
+ on(event: "hook end", listener: (hook: Hook) => void): this;
1633
+ once(event: "hook end", listener: (hook: Hook) => void): this;
1634
+ addListener(event: "hook end", listener: (hook: Hook) => void): this;
1635
+ removeListener(event: "hook end", listener: (hook: Hook) => void): this;
1636
+ prependListener(event: "hook end", listener: (hook: Hook) => void): this;
1637
+ prependOnceListener(event: "hook end", listener: (hook: Hook) => void): this;
1638
+ emit(name: "hook end", hook: Hook): boolean;
1639
+ }
1640
+ // #endregion Runner "hook end" event
1641
+ // #region Runner "pass" event
1642
+ interface Runner extends NodeJS.EventEmitter {
1643
+ on(event: "pass", listener: (test: Test) => void): this;
1644
+ once(event: "pass", listener: (test: Test) => void): this;
1645
+ addListener(event: "pass", listener: (test: Test) => void): this;
1646
+ removeListener(event: "pass", listener: (test: Test) => void): this;
1647
+ prependListener(event: "pass", listener: (test: Test) => void): this;
1648
+ prependOnceListener(event: "pass", listener: (test: Test) => void): this;
1649
+ emit(name: "pass", test: Test): boolean;
1650
+ }
1651
+ // #endregion Runner "pass" event
1652
+ // #region Runner "fail" event
1653
+ interface Runner extends NodeJS.EventEmitter {
1654
+ on(event: "fail", listener: (test: Test, err: any) => void): this;
1655
+ once(event: "fail", listener: (test: Test, err: any) => void): this;
1656
+ addListener(event: "fail", listener: (test: Test, err: any) => void): this;
1657
+ removeListener(event: "fail", listener: (test: Test, err: any) => void): this;
1658
+ prependListener(event: "fail", listener: (test: Test, err: any) => void): this;
1659
+ prependOnceListener(event: "fail", listener: (test: Test, err: any) => void): this;
1660
+ emit(name: "fail", test: Test, err: any): boolean;
1661
+ }
1662
+ // #endregion Runner "fail" event
1663
+ // #region Runner "pending" event
1664
+ interface Runner extends NodeJS.EventEmitter {
1665
+ on(event: "pending", listener: (test: Test) => void): this;
1666
+ once(event: "pending", listener: (test: Test) => void): this;
1667
+ addListener(event: "pending", listener: (test: Test) => void): this;
1668
+ removeListener(event: "pending", listener: (test: Test) => void): this;
1669
+ prependListener(event: "pending", listener: (test: Test) => void): this;
1670
+ prependOnceListener(event: "pending", listener: (test: Test) => void): this;
1671
+ emit(name: "pending", test: Test): boolean;
1672
+ }
1673
+ // #endregion Runner "pending" event
1674
+ // #region Runner untyped events
1675
+ interface Runner extends NodeJS.EventEmitter {
1676
+ on(event: string, listener: (...args: any[]) => void): this;
1677
+ once(event: string, listener: (...args: any[]) => void): this;
1678
+ addListener(event: string, listener: (...args: any[]) => void): this;
1679
+ removeListener(event: string, listener: (...args: any[]) => void): this;
1680
+ prependListener(event: string, listener: (...args: any[]) => void): this;
1681
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
1682
+ emit(name: string, ...args: any[]): boolean;
1683
+ }
1684
+ // #endregion Runner untyped events
1685
+
1686
+ /**
1687
+ * Initialize a new `Suite` with the given `title` and `ctx`.
1688
+ *
1689
+ * @see https://mochajs.org/api/Mocha.Suite.html
1690
+ */
1691
+ class Suite {
1692
+ private _beforeEach;
1693
+ private _beforeAll;
1694
+ private _afterEach;
1695
+ private _afterAll;
1696
+ private _timeout;
1697
+ private _enableTimeouts;
1698
+ private _slow;
1699
+ private _bail;
1700
+ private _retries;
1701
+ private _onlyTests;
1702
+ private _onlySuites;
1703
+
1704
+ constructor(title: string, parentContext?: Context);
1705
+ /** @deprecated Use the overload that accepts `Mocha.Context` instead. */
1706
+ constructor(title: string, parentContext?: IContext);
1707
+
1708
+ ctx: Context;
1709
+ suites: Suite[];
1710
+ tests: Test[];
1711
+ pending: boolean;
1712
+ file?: string;
1713
+ root: boolean;
1714
+ delayed: boolean;
1715
+ parent: Suite | undefined;
1716
+ title: string;
1717
+
1718
+ /**
1719
+ * Create a new `Suite` with the given `title` and parent `Suite`. When a suite
1720
+ * with the same title is already present, that suite is returned to provide
1721
+ * nicer reporter and more flexible meta-testing.
1722
+ *
1723
+ * @see https://mochajs.org/api/mocha#.exports.create
1724
+ */
1725
+ static create(parent: Suite, title: string): Suite;
1726
+ /** @deprecated Use the overload that accepts `Mocha.Suite` instead. */
1727
+ static create(parent: ISuite, title: string): Suite;
1728
+
1729
+ /**
1730
+ * Return a clone of this `Suite`.
1731
+ *
1732
+ * @see https://mochajs.org/api/Mocha.Suite.html#clone
1733
+ */
1734
+ clone(): Suite;
1735
+
1736
+ /**
1737
+ * Get timeout `ms`.
1738
+ *
1739
+ * @see https://mochajs.org/api/Mocha.Suite.html#timeout
1740
+ */
1741
+ timeout(): number;
1742
+
1743
+ /**
1744
+ * Set timeout `ms` or short-hand such as "2s".
1745
+ *
1746
+ * @see https://mochajs.org/api/Mocha.Suite.html#timeout
1747
+ */
1748
+ timeout(ms: string | number): this;
1749
+
1750
+ /**
1751
+ * Get number of times to retry a failed test.
1752
+ *
1753
+ * @see https://mochajs.org/api/Mocha.Suite.html#retries
1754
+ */
1755
+ retries(): number;
1756
+
1757
+ /**
1758
+ * Set number of times to retry a failed test.
1759
+ *
1760
+ * @see https://mochajs.org/api/Mocha.Suite.html#retries
1761
+ */
1762
+ retries(n: string | number): this;
1763
+
1764
+ /**
1765
+ * Get whether timeouts are enabled.
1766
+ *
1767
+ * @see https://mochajs.org/api/Mocha.Suite.html#enableTimeouts
1768
+ */
1769
+ enableTimeouts(): boolean;
1770
+
1771
+ /**
1772
+ * Set whether timeouts are `enabled`.
1773
+ *
1774
+ * @see https://mochajs.org/api/Mocha.Suite.html#enableTimeouts
1775
+ */
1776
+ enableTimeouts(enabled: boolean): this;
1777
+
1778
+ /**
1779
+ * Get slow `ms`.
1780
+ *
1781
+ * @see https://mochajs.org/api/Mocha.Suite.html#slow
1782
+ */
1783
+ slow(): number;
1784
+
1785
+ /**
1786
+ * Set slow `ms` or short-hand such as "2s".
1787
+ *
1788
+ * @see https://mochajs.org/api/Mocha.Suite.html#slow
1789
+ */
1790
+ slow(ms: string | number): this;
1791
+
1792
+ /**
1793
+ * Get whether to bail after first error.
1794
+ *
1795
+ * @see https://mochajs.org/api/Mocha.Suite.html#bail
1796
+ */
1797
+ bail(): boolean;
1798
+
1799
+ /**
1800
+ * Set whether to bail after first error.
1801
+ *
1802
+ * @see https://mochajs.org/api/Mocha.Suite.html#bail
1803
+ */
1804
+ bail(bail: boolean): this;
1805
+
1806
+ /**
1807
+ * Check if this suite or its parent suite is marked as pending.
1808
+ *
1809
+ * @see https://mochajs.org/api/Mocha.Suite.html#isPending
1810
+ */
1811
+ isPending(): boolean;
1812
+
1813
+ /**
1814
+ * Run `fn(test[, done])` before running tests.
1815
+ *
1816
+ * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll
1817
+ */
1818
+ beforeAll(fn?: Func): this;
1819
+
1820
+ /**
1821
+ * Run `fn(test[, done])` before running tests.
1822
+ *
1823
+ * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll
1824
+ */
1825
+ beforeAll(fn?: AsyncFunc): this;
1826
+
1827
+ /**
1828
+ * Run `fn(test[, done])` before running tests.
1829
+ *
1830
+ * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll
1831
+ */
1832
+ beforeAll(title: string, fn?: Func): this;
1833
+
1834
+ /**
1835
+ * Run `fn(test[, done])` before running tests.
1836
+ *
1837
+ * @see https://mochajs.org/api/Mocha.Suite.html#beforeAll
1838
+ */
1839
+ beforeAll(title: string, fn?: AsyncFunc): this;
1840
+
1841
+ /**
1842
+ * Run `fn(test[, done])` after running tests.
1843
+ *
1844
+ * @see https://mochajs.org/api/Mocha.Suite.html#afterAll
1845
+ */
1846
+ afterAll(fn?: Func): this;
1847
+
1848
+ /**
1849
+ * Run `fn(test[, done])` after running tests.
1850
+ *
1851
+ * @see https://mochajs.org/api/Mocha.Suite.html#afterAll
1852
+ */
1853
+ afterAll(fn?: AsyncFunc): this;
1854
+
1855
+ /**
1856
+ * Run `fn(test[, done])` after running tests.
1857
+ *
1858
+ * @see https://mochajs.org/api/Mocha.Suite.html#afterAll
1859
+ */
1860
+ afterAll(title: string, fn?: Func): this;
1861
+
1862
+ /**
1863
+ * Run `fn(test[, done])` after running tests.
1864
+ *
1865
+ * @see https://mochajs.org/api/Mocha.Suite.html#afterAll
1866
+ */
1867
+ afterAll(title: string, fn?: AsyncFunc): this;
1868
+
1869
+ /**
1870
+ * Run `fn(test[, done])` before each test case.
1871
+ *
1872
+ * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach
1873
+ */
1874
+ beforeEach(fn?: Func): this;
1875
+
1876
+ /**
1877
+ * Run `fn(test[, done])` before each test case.
1878
+ *
1879
+ * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach
1880
+ */
1881
+ beforeEach(fn?: AsyncFunc): this;
1882
+
1883
+ /**
1884
+ * Run `fn(test[, done])` before each test case.
1885
+ *
1886
+ * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach
1887
+ */
1888
+ beforeEach(title: string, fn?: Func): this;
1889
+
1890
+ /**
1891
+ * Run `fn(test[, done])` before each test case.
1892
+ *
1893
+ * @see https://mochajs.org/api/Mocha.Suite.html#beforeEach
1894
+ */
1895
+ beforeEach(title: string, fn?: AsyncFunc): this;
1896
+
1897
+ /**
1898
+ * Run `fn(test[, done])` after each test case.
1899
+ *
1900
+ * @see https://mochajs.org/api/Mocha.Suite.html#afterEach
1901
+ */
1902
+ afterEach(fn?: Func): this;
1903
+
1904
+ /**
1905
+ * Run `fn(test[, done])` after each test case.
1906
+ *
1907
+ * @see https://mochajs.org/api/Mocha.Suite.html#afterEach
1908
+ */
1909
+ afterEach(fn?: AsyncFunc): this;
1910
+
1911
+ /**
1912
+ * Run `fn(test[, done])` after each test case.
1913
+ *
1914
+ * @see https://mochajs.org/api/Mocha.Suite.html#afterEach
1915
+ */
1916
+ afterEach(title: string, fn?: Func): this;
1917
+
1918
+ /**
1919
+ * Run `fn(test[, done])` after each test case.
1920
+ *
1921
+ * @see https://mochajs.org/api/Mocha.Suite.html#afterEach
1922
+ */
1923
+ afterEach(title: string, fn?: AsyncFunc): this;
1924
+
1925
+ /**
1926
+ * Add a test `suite`.
1927
+ *
1928
+ * @see https://mochajs.org/api/Mocha.Suite.html#addSuite
1929
+ */
1930
+ addSuite(suite: Suite): this;
1931
+ /** @deprecated Use the overload that accepts `Mocha.ISuite` instead. */
1932
+ addSuite(suite: ISuite): this;
1933
+
1934
+ /**
1935
+ * Add a `test` to this suite.
1936
+ *
1937
+ * @see https://mochajs.org/api/Mocha.Suite.html#addTest
1938
+ */
1939
+ addTest(test: Test): this;
1940
+ /** @deprecated Use the overload that accepts `Mocha.ITest` instead. */
1941
+ addTest(test: ITest): this;
1942
+
1943
+ /**
1944
+ * Return the full title generated by recursively concatenating the parent's
1945
+ * full title.
1946
+ *
1947
+ * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#fullTitle
1948
+ */
1949
+ fullTitle(): string;
1950
+
1951
+ /**
1952
+ * Return the title path generated by recursively concatenating the parent's
1953
+ * title path.
1954
+ *
1955
+ * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#titlePath
1956
+ */
1957
+ titlePath(): string[];
1958
+
1959
+ /**
1960
+ * Return the total number of tests.
1961
+ *
1962
+ * @see https://mochajs.org/api/Mocha.Suite.html#.Suite#total
1963
+ */
1964
+ total(): number;
1965
+
1966
+ /**
1967
+ * Iterates through each suite recursively to find all tests. Applies a
1968
+ * function in the format `fn(test)`.
1969
+ *
1970
+ * @see https://mochajs.org/api/Mocha.Suite.html#eachTest
1971
+ */
1972
+ eachTest(fn: (test: Test) => void): this;
1973
+
1974
+ /**
1975
+ * This will run the root suite if we happen to be running in delayed mode.
1976
+ *
1977
+ * @see https://mochajs.org/api/Mocha.Suite.html#run
1978
+ */
1979
+ run(): void;
1980
+
1981
+ /**
1982
+ * Generic hook-creator.
1983
+ */
1984
+ protected _createHook(title: string, fn?: Func | AsyncFunc): Hook;
1985
+ }
1986
+
1987
+ // #region Suite "beforeAll" event
1988
+ interface Suite extends NodeJS.EventEmitter {
1989
+ on(event: "beforeAll", listener: (hook: Hook) => void): this;
1990
+ once(event: "beforeAll", listener: (hook: Hook) => void): this;
1991
+ addListener(event: "beforeAll", listener: (hook: Hook) => void): this;
1992
+ removeListener(event: "beforeAll", listener: (hook: Hook) => void): this;
1993
+ prependListener(event: "beforeAll", listener: (hook: Hook) => void): this;
1994
+ prependOnceListener(event: "beforeAll", listener: (hook: Hook) => void): this;
1995
+ emit(name: "beforeAll", hook: Hook): boolean;
1996
+ }
1997
+ // #endregion Suite "beforeAll" event
1998
+ // #region Suite "afterAll" event
1999
+ interface Suite extends NodeJS.EventEmitter {
2000
+ on(event: "afterAll", listener: (hook: Hook) => void): this;
2001
+ once(event: "afterAll", listener: (hook: Hook) => void): this;
2002
+ addListener(event: "afterAll", listener: (hook: Hook) => void): this;
2003
+ removeListener(event: "afterAll", listener: (hook: Hook) => void): this;
2004
+ prependListener(event: "afterAll", listener: (hook: Hook) => void): this;
2005
+ prependOnceListener(event: "afterAll", listener: (hook: Hook) => void): this;
2006
+ emit(name: "afterAll", hook: Hook): boolean;
2007
+ }
2008
+ // #endregion Suite "afterAll" event
2009
+ // #region Suite "beforeEach" event
2010
+ interface Suite extends NodeJS.EventEmitter {
2011
+ on(event: "beforeEach", listener: (hook: Hook) => void): this;
2012
+ once(event: "beforeEach", listener: (hook: Hook) => void): this;
2013
+ addListener(event: "beforeEach", listener: (hook: Hook) => void): this;
2014
+ removeListener(event: "beforeEach", listener: (hook: Hook) => void): this;
2015
+ prependListener(event: "beforeEach", listener: (hook: Hook) => void): this;
2016
+ prependOnceListener(event: "beforeEach", listener: (hook: Hook) => void): this;
2017
+ emit(name: "beforeEach", hook: Hook): boolean;
2018
+ }
2019
+ // #endregion Suite "beforeEach" event
2020
+ // #region Suite "afterEach" event
2021
+ interface Suite extends NodeJS.EventEmitter {
2022
+ on(event: "afterEach", listener: (hook: Hook) => void): this;
2023
+ once(event: "afterEach", listener: (hook: Hook) => void): this;
2024
+ addListener(event: "afterEach", listener: (hook: Hook) => void): this;
2025
+ removeListener(event: "afterEach", listener: (hook: Hook) => void): this;
2026
+ prependListener(event: "afterEach", listener: (hook: Hook) => void): this;
2027
+ prependOnceListener(event: "afterEach", listener: (hook: Hook) => void): this;
2028
+ emit(name: "afterEach", hook: Hook): boolean;
2029
+ }
2030
+ // #endregion Suite "afterEach" event
2031
+ // #region Suite "suite" event
2032
+ interface Suite extends NodeJS.EventEmitter {
2033
+ on(event: "suite", listener: (suite: Suite) => void): this;
2034
+ once(event: "suite", listener: (suite: Suite) => void): this;
2035
+ addListener(event: "suite", listener: (suite: Suite) => void): this;
2036
+ removeListener(event: "suite", listener: (suite: Suite) => void): this;
2037
+ prependListener(event: "suite", listener: (suite: Suite) => void): this;
2038
+ prependOnceListener(event: "suite", listener: (suite: Suite) => void): this;
2039
+ emit(name: "suite", suite: Suite): boolean;
2040
+ }
2041
+ // #endregion Suite "suite" event
2042
+ // #region Suite "test" event
2043
+ interface Suite {
2044
+ on(event: "test", listener: (test: Test) => void): this;
2045
+ once(event: "test", listener: (test: Test) => void): this;
2046
+ addListener(event: "test", listener: (test: Test) => void): this;
2047
+ removeListener(event: "test", listener: (test: Test) => void): this;
2048
+ prependListener(event: "test", listener: (test: Test) => void): this;
2049
+ prependOnceListener(event: "test", listener: (test: Test) => void): this;
2050
+ emit(name: "test", test: Test): boolean;
2051
+ }
2052
+ // #endregion Suite "test" event
2053
+ // #region Suite "run" event
2054
+ interface Suite extends NodeJS.EventEmitter {
2055
+ on(event: "run", listener: () => void): this;
2056
+ once(event: "run", listener: () => void): this;
2057
+ addListener(event: "run", listener: () => void): this;
2058
+ removeListener(event: "run", listener: () => void): this;
2059
+ prependListener(event: "run", listener: () => void): this;
2060
+ prependOnceListener(event: "run", listener: () => void): this;
2061
+ emit(name: "run"): boolean;
2062
+ }
2063
+ // #endregion Suite "run" event
2064
+ // #region Suite "pre-require" event
2065
+ interface Suite extends NodeJS.EventEmitter {
2066
+ on(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this;
2067
+ once(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this;
2068
+ addListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this;
2069
+ removeListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this;
2070
+ prependListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this;
2071
+ prependOnceListener(event: "pre-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this;
2072
+ emit(name: "pre-require", context: MochaGlobals, file: string, mocha: Mocha): boolean;
2073
+ }
2074
+ // #endregion Suite "pre-require" event
2075
+ // #region Suite "require" event
2076
+ interface Suite extends NodeJS.EventEmitter {
2077
+ on(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this;
2078
+ once(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this;
2079
+ addListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this;
2080
+ removeListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this;
2081
+ prependListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this;
2082
+ prependOnceListener(event: "require", listener: (module: any, file: string, mocha: Mocha) => void): this;
2083
+ emit(name: "require", module: any, file: string, mocha: Mocha): boolean;
2084
+ }
2085
+ // #endregion Suite "require" event
2086
+ // #region Suite "post-require" event
2087
+ interface Suite extends NodeJS.EventEmitter {
2088
+ on(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this;
2089
+ once(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this;
2090
+ addListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this;
2091
+ removeListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this;
2092
+ prependListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this;
2093
+ prependOnceListener(event: "post-require", listener: (context: MochaGlobals, file: string, mocha: Mocha) => void): this;
2094
+ emit(name: "post-require", context: MochaGlobals, file: string, mocha: Mocha): boolean;
2095
+ }
2096
+ // #endregion Suite "post-require" event
2097
+ // #region Suite untyped events
2098
+ interface Suite extends NodeJS.EventEmitter {
2099
+ on(event: string, listener: (...args: any[]) => void): this;
2100
+ once(event: string, listener: (...args: any[]) => void): this;
2101
+ addListener(event: string, listener: (...args: any[]) => void): this;
2102
+ removeListener(event: string, listener: (...args: any[]) => void): this;
2103
+ prependListener(event: string, listener: (...args: any[]) => void): this;
2104
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
2105
+ emit(name: string, ...args: any[]): boolean;
2106
+ }
2107
+ // #endregion Runner untyped events
2108
+
2109
+ /**
2110
+ * Initialize a new `Hook` with the given `title` and callback `fn`
2111
+ *
2112
+ * @see https://mochajs.org/api/Hook.html
2113
+ */
2114
+ class Hook extends Runnable {
2115
+ private _error;
2116
+
2117
+ type: "hook";
2118
+ originalTitle?: string; // added by Runner
2119
+
2120
+ /**
2121
+ * Get the test `err`.
2122
+ *
2123
+ * @see https://mochajs.org/api/Hook.html#error
2124
+ */
2125
+ error(): any;
2126
+
2127
+ /**
2128
+ * Set the test `err`.
2129
+ *
2130
+ * @see https://mochajs.org/api/Hook.html#error
2131
+ */
2132
+ error(err: any): void;
2133
+ }
2134
+
2135
+ /**
2136
+ * Initialize a new `Test` with the given `title` and callback `fn`.
2137
+ *
2138
+ * @see https://mochajs.org/api/Test.html
2139
+ */
2140
+ class Test extends Runnable {
2141
+ type: "test";
2142
+ speed?: "slow" | "medium" | "fast"; // added by reporters
2143
+ err?: Error; // added by reporters
2144
+ clone(): Test;
2145
+ }
2146
+
2147
+ /**
2148
+ * Test statistics
2149
+ */
2150
+ interface Stats {
2151
+ suites: number;
2152
+ tests: number;
2153
+ passes: number;
2154
+ pending: number;
2155
+ failures: number;
2156
+ start?: Date;
2157
+ end?: Date;
2158
+ duration?: number;
2159
+ }
2160
+
2161
+ type TestInterface = (suite: Suite) => void;
2162
+
2163
+ interface ReporterConstructor {
2164
+ new (runner: Runner, options: MochaOptions): reporters.Base;
2165
+ }
2166
+
2167
+ type Done = (err?: any) => void;
2168
+
2169
+ /**
2170
+ * Callback function used for tests and hooks.
2171
+ */
2172
+ type Func = (this: Context, done: Done) => void;
2173
+
2174
+ /**
2175
+ * Async callback function used for tests and hooks.
2176
+ */
2177
+ type AsyncFunc = (this: Context) => PromiseLike<any>;
2178
+
2179
+ /**
2180
+ * Options to pass to Mocha.
2181
+ */
2182
+ interface MochaOptions {
2183
+ /** Test interfaces ("bdd", "tdd", "exports", etc.). */
2184
+ ui?: Interface;
2185
+
2186
+ /**
2187
+ * Reporter constructor, built-in reporter name, or reporter module path. Defaults to
2188
+ * `"spec"`.
2189
+ */
2190
+ reporter?: string | ReporterConstructor;
2191
+
2192
+ /** Options to pass to the reporter. */
2193
+ reporterOptions?: any;
2194
+
2195
+ /** Array of accepted globals. */
2196
+ globals?: string[];
2197
+
2198
+ /** timeout in milliseconds. */
2199
+ timeout?: number;
2200
+
2201
+ enableTimeouts?: boolean;
2202
+
2203
+ /** number of times to retry failed tests. */
2204
+ retries?: number;
2205
+
2206
+ /** bail on the first test failure. */
2207
+ bail?: boolean;
2208
+
2209
+ /** milliseconds to wait before considering a test slow. */
2210
+ slow?: number;
2211
+
2212
+ /** ignore global leaks. */
2213
+ ignoreLeaks?: boolean;
2214
+
2215
+ /** display the full stack trace on failure. */
2216
+ fullStackTrace?: boolean;
2217
+
2218
+ /** string or regexp to filter tests with. */
2219
+ grep?: string | RegExp;
2220
+
2221
+ /** Enable growl support. */
2222
+ growl?: boolean;
2223
+
2224
+ /** Emit color output. */
2225
+ useColors?: boolean;
2226
+
2227
+ /** Use inline diffs rather than +/-. */
2228
+ inlineDiffs?: boolean;
2229
+
2230
+ /** Do not show diffs at all. */
2231
+ hideDiff?: boolean;
2232
+
2233
+ asyncOnly?: boolean;
2234
+ delay?: boolean;
2235
+ forbidOnly?: boolean;
2236
+ forbidPending?: boolean;
2237
+ noHighlighting?: boolean;
2238
+ allowUncaught?: boolean;
2239
+ }
2240
+
2241
+ interface MochaInstanceOptions extends MochaOptions {
2242
+ files?: string[];
2243
+ }
2244
+
2245
+ /**
2246
+ * Variables added to the global scope by Mocha when run in the CLI.
2247
+ */
2248
+ interface MochaGlobals {
2249
+ /**
2250
+ * Execute before running tests.
2251
+ *
2252
+ * - _Only available when invoked via the mocha CLI._
2253
+ *
2254
+ * @see https://mochajs.org/api/global.html#before
2255
+ */
2256
+ before: HookFunction;
2257
+
2258
+ /**
2259
+ * Execute after running tests.
2260
+ *
2261
+ * - _Only available when invoked via the mocha CLI._
2262
+ *
2263
+ * @see https://mochajs.org/api/global.html#after
2264
+ */
2265
+ after: HookFunction;
2266
+
2267
+ /**
2268
+ * Execute before each test case.
2269
+ *
2270
+ * - _Only available when invoked via the mocha CLI._
2271
+ *
2272
+ * @see https://mochajs.org/api/global.html#beforeEach
2273
+ */
2274
+ beforeEach: HookFunction;
2275
+
2276
+ /**
2277
+ * Execute after each test case.
2278
+ *
2279
+ * - _Only available when invoked via the mocha CLI._
2280
+ *
2281
+ * @see https://mochajs.org/api/global.html#afterEach
2282
+ */
2283
+ afterEach: HookFunction;
2284
+
2285
+ /**
2286
+ * Describe a "suite" containing nested suites and tests.
2287
+ *
2288
+ * - _Only available when invoked via the mocha CLI._
2289
+ */
2290
+ describe: SuiteFunction;
2291
+
2292
+ /**
2293
+ * Describe a "suite" containing nested suites and tests.
2294
+ *
2295
+ * - _Only available when invoked via the mocha CLI._
2296
+ */
2297
+ context: SuiteFunction;
2298
+
2299
+ /**
2300
+ * Pending suite.
2301
+ *
2302
+ * - _Only available when invoked via the mocha CLI._
2303
+ */
2304
+ xdescribe: PendingSuiteFunction;
2305
+
2306
+ /**
2307
+ * Pending suite.
2308
+ *
2309
+ * - _Only available when invoked via the mocha CLI._
2310
+ */
2311
+ xcontext: PendingSuiteFunction;
2312
+
2313
+ /**
2314
+ * Describes a test case.
2315
+ *
2316
+ * - _Only available when invoked via the mocha CLI._
2317
+ */
2318
+ it: TestFunction;
2319
+
2320
+ /**
2321
+ * Describes a test case.
2322
+ *
2323
+ * - _Only available when invoked via the mocha CLI._
2324
+ */
2325
+ specify: TestFunction;
2326
+
2327
+ /**
2328
+ * Describes a pending test case.
2329
+ *
2330
+ * - _Only available when invoked via the mocha CLI._
2331
+ */
2332
+ xit: PendingTestFunction;
2333
+
2334
+ /**
2335
+ * Describes a pending test case.
2336
+ *
2337
+ * - _Only available when invoked via the mocha CLI._
2338
+ */
2339
+ xspecify: PendingTestFunction;
2340
+
2341
+ /**
2342
+ * Execute before running tests.
2343
+ *
2344
+ * - _Only available when invoked via the mocha CLI._
2345
+ *
2346
+ * @see https://mochajs.org/api/global.html#before
2347
+ */
2348
+ suiteSetup: HookFunction;
2349
+
2350
+ /**
2351
+ * Execute after running tests.
2352
+ *
2353
+ * - _Only available when invoked via the mocha CLI._
2354
+ *
2355
+ * @see https://mochajs.org/api/global.html#after
2356
+ */
2357
+ suiteTeardown: HookFunction;
2358
+
2359
+ /**
2360
+ * Execute before each test case.
2361
+ *
2362
+ * - _Only available when invoked via the mocha CLI._
2363
+ *
2364
+ * @see https://mochajs.org/api/global.html#beforeEach
2365
+ */
2366
+ setup: HookFunction;
2367
+
2368
+ /**
2369
+ * Execute after each test case.
2370
+ *
2371
+ * - _Only available when invoked via the mocha CLI._
2372
+ *
2373
+ * @see https://mochajs.org/api/global.html#afterEach
2374
+ */
2375
+ teardown: HookFunction;
2376
+
2377
+ /**
2378
+ * Describe a "suite" containing nested suites and tests.
2379
+ *
2380
+ * - _Only available when invoked via the mocha CLI._
2381
+ */
2382
+ suite: SuiteFunction;
2383
+
2384
+ /**
2385
+ * Describes a test case.
2386
+ *
2387
+ * - _Only available when invoked via the mocha CLI._
2388
+ */
2389
+ test: TestFunction;
2390
+
2391
+ run: typeof run;
2392
+ }
2393
+
2394
+ /**
2395
+ * Third-party declarations that want to add new entries to the `Reporter` union can
2396
+ * contribute names here.
2397
+ */
2398
+ interface ReporterContributions {
2399
+ Base: never;
2400
+ base: never;
2401
+ Dot: never;
2402
+ dot: never;
2403
+ TAP: never;
2404
+ tap: never;
2405
+ JSON: never;
2406
+ json: never;
2407
+ HTML: never;
2408
+ html: never;
2409
+ List: never;
2410
+ list: never;
2411
+ Min: never;
2412
+ min: never;
2413
+ Spec: never;
2414
+ spec: never;
2415
+ Nyan: never;
2416
+ nyan: never;
2417
+ XUnit: never;
2418
+ xunit: never;
2419
+ Markdown: never;
2420
+ markdown: never;
2421
+ Progress: never;
2422
+ progress: never;
2423
+ Landing: never;
2424
+ landing: never;
2425
+ JSONStream: never;
2426
+ "json-stream": never;
2427
+ }
2428
+
2429
+ type Reporter = keyof ReporterContributions;
2430
+
2431
+ /**
2432
+ * Third-party declarations that want to add new entries to the `Interface` union can
2433
+ * contribute names here.
2434
+ */
2435
+ interface InterfaceContributions {
2436
+ bdd: never;
2437
+ tdd: never;
2438
+ qunit: never;
2439
+ exports: never;
2440
+ }
2441
+
2442
+ type Interface = keyof InterfaceContributions;
2443
+
2444
+ // #region Deprecations
2445
+
2446
+ /** @deprecated use `Mocha.Context` instead. */
2447
+ interface IContext {
2448
+ test?: IRunnable;
2449
+ runnable(): IRunnable | undefined;
2450
+ /** @deprecated `.runnable()` returns `this` in `Mocha.Context`. */
2451
+ runnable(runnable: IRunnable): IContext;
2452
+ timeout(): number;
2453
+ /** @deprecated `.timeout()` returns `this` in `Mocha.Context`. */
2454
+ timeout(timeout: number): IContext;
2455
+ /** @deprecated `.enableTimeouts()` has additional overloads in `Mocha.Context`. */
2456
+ /** @deprecated `.enableTimeouts()` returns `this` in `Mocha.Context`. */
2457
+ enableTimeouts(enableTimeouts: boolean): IContext;
2458
+ /** @deprecated `.slow()` has additional overloads in `Mocha.Context`. */
2459
+ /** @deprecated `.slow()` returns `this` in `Mocha.Context`. */
2460
+ slow(slow: number): IContext;
2461
+ /** @deprecated `.skip()` returns `never` in `Mocha.Context`. */
2462
+ skip(): IContext;
2463
+ retries(): number;
2464
+ /** @deprecated `.retries()` returns `this` in `Mocha.Context`. */
2465
+ retries(retries: number): IContext;
2466
+ }
2467
+
2468
+ /** @deprecated use `Mocha.Suite` instead. */
2469
+ interface ISuiteCallbackContext {
2470
+ /** @deprecated `.timeout()` has additional overloads in `Mocha.Suite`. */
2471
+ timeout(ms: number | string): this;
2472
+ /** @deprecated `.retries()` has additional overloads in `Mocha.Suite`. */
2473
+ retries(n: number): this;
2474
+ /** @deprecated `.slow()` has additional overloads in `Mocha.Suite`. */
2475
+ slow(ms: number): this;
2476
+ }
2477
+
2478
+ /** @deprecated use `Mocha.Context` instead. */
2479
+ interface IHookCallbackContext {
2480
+ /** @deprecated `.skip()` returns `never` in `Mocha.Context`. */
2481
+ skip(): this;
2482
+ /** @deprecated `.timeout()` has additional overloads in `Mocha.Context`. */
2483
+ timeout(ms: number | string): this;
2484
+ [index: string]: any;
2485
+ }
2486
+
2487
+ /** @deprecated use `Mocha.Context` instead. */
2488
+ interface ITestCallbackContext {
2489
+ /** @deprecated `.skip()` returns `never` in `Mocha.Context`. */
2490
+ skip(): this;
2491
+ /** @deprecated `.timeout()` has additional overloads in `Mocha.Context`. */
2492
+ timeout(ms: number | string): this;
2493
+ /** @deprecated `.retries()` has additional overloads in `Mocha.Context`. */
2494
+ retries(n: number): this;
2495
+ /** @deprecated `.slow()` has additional overloads in `Mocha.Context`. */
2496
+ slow(ms: number): this;
2497
+ [index: string]: any;
2498
+ }
2499
+
2500
+ /** Partial interface for Mocha's `Runnable` class. */
2501
+ /** @deprecated use `Mocha.Runnable` instead. */
2502
+ interface IRunnable extends NodeJS.EventEmitter {
2503
+ title: string;
2504
+ /** @deprecated `.fn` has type `Func | AsyncFunc` in `Mocha.Runnable`. */
2505
+ fn: Function | undefined;
2506
+ async: boolean;
2507
+ sync: boolean;
2508
+ timedOut: boolean;
2509
+ /** @deprecated `.timeout()` has additional overloads in `Mocha.Runnable`. */
2510
+ timeout(n: number | string): this;
2511
+ duration?: number;
2512
+ }
2513
+
2514
+ /** Partial interface for Mocha's `Suite` class. */
2515
+ /** @deprecated use `Mocha.Suite` instead. */
2516
+ interface ISuite {
2517
+ /** @deprecated `.ctx` has type `Mocha.Context` in `Mocha.Suite`. */
2518
+ ctx: IContext;
2519
+ /** @deprecated `.parent` has type `Mocha.Suite | undefined` in `Mocha.Suite`. */
2520
+ parent: ISuite | undefined;
2521
+ root: boolean;
2522
+ title: string;
2523
+ /** @deprecated `.suites` has type `Mocha.Suite[]` in `Mocha.Suite`. */
2524
+ suites: ISuite[];
2525
+ /** @deprecated `.tests` has type `Mocha.Test[]` in `Mocha.Suite`. */
2526
+ tests: ITest[];
2527
+
2528
+ bail(): boolean;
2529
+ /** @deprecated `.bail()` returns `this` in `Mocha.Suite`. */
2530
+ bail(bail: boolean): ISuite;
2531
+ fullTitle(): string;
2532
+ retries(): number;
2533
+ /** @deprecated `.retries()` returns `this` in `Mocha.Suite`. */
2534
+ retries(retries: number): ISuite;
2535
+ slow(): number;
2536
+ /** @deprecated `.slow()` returns `this` in `Mocha.Suite`. */
2537
+ slow(slow: number): ISuite;
2538
+ timeout(): number;
2539
+ /** @deprecated `.timeout()` returns `this` in `Mocha.Suite`. */
2540
+ timeout(timeout: number): ISuite;
2541
+ }
2542
+
2543
+ /** Partial interface for Mocha's `Test` class. */
2544
+ /** @deprecated use `Mocha.Test` instead. */
2545
+ interface ITest extends IRunnable {
2546
+ body?: string;
2547
+ file?: string;
2548
+ /** @deprecated `.parent` has type `Mocha.Suite | undefined` in `Mocha.Test`. */
2549
+ parent?: ISuite;
2550
+ pending: boolean;
2551
+ state?: 'failed' | 'passed';
2552
+ type: 'test';
2553
+ fullTitle(): string;
2554
+ }
2555
+
2556
+ /** @deprecated use `Mocha.Hook` instead. */
2557
+ interface IHook extends IRunnable {
2558
+ /** @deprecated `.ctx` has type `Mocha.Context` in `Mocha.Runnable`. */
2559
+ ctx?: IContext;
2560
+ /** @deprecated `.parent` has type `Mocha.Suite` in `Mocha.Runnable`. */
2561
+ parent?: ISuite;
2562
+ type: 'hook';
2563
+ /** @deprecated `.error()` has additional overloads in `Mocha.Hook`. */
2564
+ error(err: Error): void;
2565
+ }
2566
+
2567
+ /** @deprecated use `Mocha.Context` instead. */
2568
+ interface IBeforeAndAfterContext extends IHookCallbackContext {
2569
+ /** @deprecated `.currentTest` has type `Mocha.Test` in `Mocha.Context`. */
2570
+ currentTest?: ITest;
2571
+ }
2572
+
2573
+ /** @deprecated use `Mocha.Stats` instead. */
2574
+ type IStats = Stats;
2575
+
2576
+ /** Partial interface for Mocha's `Runner` class. */
2577
+ /** @deprecated use `Mocha.Runner` instead. */
2578
+ interface IRunner extends NodeJS.EventEmitter {
2579
+ asyncOnly?: boolean;
2580
+ stats?: IStats;
2581
+ started: boolean;
2582
+ /** @deprecated `.suite` has type `Mocha.Suite` in `Mocha.Runner`. */
2583
+ suite: ISuite;
2584
+ total: number;
2585
+ failures: number;
2586
+ forbidOnly?: boolean;
2587
+ forbidPending?: boolean;
2588
+ fullStackTrace?: boolean;
2589
+ ignoreLeaks?: boolean;
2590
+ grep(re: RegExp, invert: boolean): this;
2591
+ /** @deprecated Parameter `suite` has type `Mocha.Suite` in `Mocha.Runner`. */
2592
+ grepTotal(suite: ISuite): number;
2593
+ /** @deprecated `.globals()` has different overloads in `Mocha.Runner`. */
2594
+ globals(arr: ReadonlyArray<string>): this | string[];
2595
+ abort(): this;
2596
+ run(fn?: (failures: number) => void): this;
2597
+ }
2598
+
2599
+ /** @deprecated use `Mocha.SuiteFunction` instead. */
2600
+ interface IContextDefinition {
2601
+ /** @deprecated use `Mocha.SuiteFunction` instead. */
2602
+ (description: string, callback: (this: ISuiteCallbackContext) => void): ISuite;
2603
+ /** @deprecated use `Mocha.SuiteFunction` instead. */
2604
+ only(description: string, callback: (this: ISuiteCallbackContext) => void): ISuite;
2605
+ /** @deprecated use `Mocha.SuiteFunction` instead. */
2606
+ skip(description: string, callback: (this: ISuiteCallbackContext) => void): void;
2607
+ }
2608
+
2609
+ /** @deprecated use `Mocha.TestFunction` instead. */
2610
+ interface ITestDefinition {
2611
+ /** @deprecated use `Mocha.TestFunction` instead. */
2612
+ /** @deprecated `Mocha.TestFunction` does not allow mixing `done` with a return type of `PromiseLike<any>`. */
2613
+ (expectation: string, callback?: (this: ITestCallbackContext, done: MochaDone) => PromiseLike<any> | void): ITest;
2614
+ /** @deprecated use `Mocha.TestFunction` instead. */
2615
+ /** @deprecated `Mocha.TestFunction#only` does not allow mixing `done` with a return type of `PromiseLike<any>`. */
2616
+ only(expectation: string, callback?: (this: ITestCallbackContext, done: MochaDone) => PromiseLike<any> | void): ITest;
2617
+ /** @deprecated use `Mocha.TestFunction` instead. */
2618
+ /** @deprecated `Mocha.TestFunction#skip` does not allow mixing `done` with a return type of `PromiseLike<any>`. */
2619
+ skip(expectation: string, callback?: (this: ITestCallbackContext, done: MochaDone) => PromiseLike<any> | void): void;
2620
+ }
2621
+
2622
+ // #endregion
2623
+ }
2624
+
2625
+ // #region Test interface augmentations
2626
+
2627
+ /**
2628
+ * Triggers root suite execution.
2629
+ *
2630
+ * - _Only available if flag --delay is passed into Mocha._
2631
+ * - _Only available when invoked via the mocha CLI._
2632
+ *
2633
+ * @see https://mochajs.org/api/global.html#runWithSuite
2634
+ */
2635
+ declare function run(): void;
2636
+
2637
+ /**
2638
+ * Execute before running tests.
2639
+ *
2640
+ * - _Only available when invoked via the mocha CLI._
2641
+ *
2642
+ * @see https://mochajs.org/api/global.html#before
2643
+ */
2644
+ declare var before: Mocha.HookFunction;
2645
+
2646
+ /**
2647
+ * Execute before running tests.
2648
+ *
2649
+ * - _Only available when invoked via the mocha CLI._
2650
+ *
2651
+ * @see https://mochajs.org/api/global.html#before
2652
+ */
2653
+ declare var suiteSetup: Mocha.HookFunction;
2654
+
2655
+ /**
2656
+ * Execute after running tests.
2657
+ *
2658
+ * - _Only available when invoked via the mocha CLI._
2659
+ *
2660
+ * @see https://mochajs.org/api/global.html#after
2661
+ */
2662
+ declare var after: Mocha.HookFunction;
2663
+
2664
+ /**
2665
+ * Execute after running tests.
2666
+ *
2667
+ * - _Only available when invoked via the mocha CLI._
2668
+ *
2669
+ * @see https://mochajs.org/api/global.html#after
2670
+ */
2671
+ declare var suiteTeardown: Mocha.HookFunction;
2672
+
2673
+ /**
2674
+ * Execute before each test case.
2675
+ *
2676
+ * - _Only available when invoked via the mocha CLI._
2677
+ *
2678
+ * @see https://mochajs.org/api/global.html#beforeEach
2679
+ */
2680
+ declare var beforeEach: Mocha.HookFunction;
2681
+
2682
+ /**
2683
+ * Execute before each test case.
2684
+ *
2685
+ * - _Only available when invoked via the mocha CLI._
2686
+ *
2687
+ * @see https://mochajs.org/api/global.html#beforeEach
2688
+ */
2689
+ declare var setup: Mocha.HookFunction;
2690
+
2691
+ /**
2692
+ * Execute after each test case.
2693
+ *
2694
+ * - _Only available when invoked via the mocha CLI._
2695
+ *
2696
+ * @see https://mochajs.org/api/global.html#afterEach
2697
+ */
2698
+ declare var afterEach: Mocha.HookFunction;
2699
+
2700
+ /**
2701
+ * Execute after each test case.
2702
+ *
2703
+ * - _Only available when invoked via the mocha CLI._
2704
+ *
2705
+ * @see https://mochajs.org/api/global.html#afterEach
2706
+ */
2707
+ declare var teardown: Mocha.HookFunction;
2708
+
2709
+ /**
2710
+ * Describe a "suite" containing nested suites and tests.
2711
+ *
2712
+ * - _Only available when invoked via the mocha CLI._
2713
+ */
2714
+ declare var describe: Mocha.SuiteFunction;
2715
+
2716
+ /**
2717
+ * Describe a "suite" containing nested suites and tests.
2718
+ *
2719
+ * - _Only available when invoked via the mocha CLI._
2720
+ */
2721
+ declare var context: Mocha.SuiteFunction;
2722
+
2723
+ /**
2724
+ * Describe a "suite" containing nested suites and tests.
2725
+ *
2726
+ * - _Only available when invoked via the mocha CLI._
2727
+ */
2728
+ declare var suite: Mocha.SuiteFunction;
2729
+
2730
+ /**
2731
+ * Pending suite.
2732
+ *
2733
+ * - _Only available when invoked via the mocha CLI._
2734
+ */
2735
+ declare var xdescribe: Mocha.PendingSuiteFunction;
2736
+
2737
+ /**
2738
+ * Pending suite.
2739
+ *
2740
+ * - _Only available when invoked via the mocha CLI._
2741
+ */
2742
+ declare var xcontext: Mocha.PendingSuiteFunction;
2743
+
2744
+ /**
2745
+ * Describes a test case.
2746
+ *
2747
+ * - _Only available when invoked via the mocha CLI._
2748
+ */
2749
+ declare var it: Mocha.TestFunction;
2750
+
2751
+ /**
2752
+ * Describes a test case.
2753
+ *
2754
+ * - _Only available when invoked via the mocha CLI._
2755
+ */
2756
+ declare var specify: Mocha.TestFunction;
2757
+
2758
+ /**
2759
+ * Describes a test case.
2760
+ *
2761
+ * - _Only available when invoked via the mocha CLI._
2762
+ */
2763
+ declare var test: Mocha.TestFunction;
2764
+
2765
+ /**
2766
+ * Describes a pending test case.
2767
+ *
2768
+ * - _Only available when invoked via the mocha CLI._
2769
+ */
2770
+ declare var xit: Mocha.PendingTestFunction;
2771
+
2772
+ /**
2773
+ * Describes a pending test case.
2774
+ *
2775
+ * - _Only available when invoked via the mocha CLI._
2776
+ */
2777
+ declare var xspecify: Mocha.PendingTestFunction;
2778
+
2779
+ // #endregion Test interface augmentations
2780
+
2781
+ // #region Reporter augmentations
2782
+
2783
+ // Forward declaration for `HTMLLIElement` from lib.dom.d.ts.
2784
+ // Required by Mocha.reporters.HTML.
2785
+ // NOTE: Mocha *must not* have a direct dependency on DOM types.
2786
+ // tslint:disable-next-line no-empty-interface
2787
+ interface HTMLLIElement { }
2788
+
2789
+ // Augments the DOM `Window` object when lib.dom.d.ts is loaded.
2790
+ // tslint:disable-next-line no-empty-interface
2791
+ interface Window extends Mocha.MochaGlobals { }
2792
+
2793
+ declare namespace NodeJS {
2794
+ // Forward declaration for `NodeJS.EventEmitter` from node.d.ts.
2795
+ // Required by Mocha.Runnable, Mocha.Runner, and Mocha.Suite.
2796
+ // NOTE: Mocha *must not* have a direct dependency on @types/node.
2797
+ // tslint:disable-next-line no-empty-interface
2798
+ interface EventEmitter { }
2799
+
2800
+ // Augments NodeJS's `global` object when node.d.ts is loaded
2801
+ // tslint:disable-next-line no-empty-interface
2802
+ interface Global extends Mocha.MochaGlobals { }
2803
+ }
2804
+
2805
+ // #endregion Reporter augmentations
2806
+
2807
+ // #region Browser augmentations
2808
+
2809
+ /**
2810
+ * Mocha global.
2811
+ *
2812
+ * - _Only supported in the browser._
2813
+ */
2814
+ declare const mocha: BrowserMocha;
2815
+
2816
+ interface BrowserMocha extends Mocha {
2817
+ /**
2818
+ * Function to allow assertion libraries to throw errors directly into mocha.
2819
+ * This is useful when running tests in a browser because window.onerror will
2820
+ * only receive the 'message' attribute of the Error.
2821
+ *
2822
+ * - _Only supported in the browser._
2823
+ */
2824
+ throwError(err: any): never;
2825
+
2826
+ /**
2827
+ * Setup mocha with the given settings options.
2828
+ *
2829
+ * - _Only supported in the browser._
2830
+ */
2831
+ setup(opts?: Mocha.Interface | MochaSetupOptions): this;
2832
+ }
2833
+
2834
+ /**
2835
+ * Options to pass to `mocha.setup` in the browser.
2836
+ */
2837
+ interface MochaSetupOptions extends Mocha.MochaOptions {
2838
+ /** @deprecated This is not used by Mocha. Use `files` instead. */
2839
+ require?: string[];
2840
+ fullTrace?: boolean;
2841
+ }
2842
+
2843
+ // #endregion Browser augmentations
2844
+
2845
+ // #region Deprecations
2846
+
2847
+ /** @deprecated use `Mocha.Done` instead. */
2848
+ type MochaDone = Mocha.Done;
2849
+
2850
+ /** @deprecated use `Mocha.ReporterConstructor` instead. */
2851
+ type ReporterConstructor = Mocha.ReporterConstructor;
2852
+
2853
+ // #endregion Deprecations
2854
+
2855
+ declare module "mocha" {
2856
+ export = Mocha;
2857
+ }
2858
+
2859
+ declare module "mocha/lib/ms" {
2860
+ export = milliseconds;
2861
+ /**
2862
+ * Parse the given `str` and return milliseconds.
2863
+ *
2864
+ * @see {@link https://mochajs.org/api/module-milliseconds.html}
2865
+ * @see {@link https://mochajs.org/api/module-milliseconds.html#~parse}
2866
+ */
2867
+ function milliseconds(val: string): number;
2868
+
2869
+ /**
2870
+ * Format for `ms`.
2871
+ *
2872
+ * @see {@link https://mochajs.org/api/module-milliseconds.html}
2873
+ * @see {@link https://mochajs.org/api/module-milliseconds.html#~format}
2874
+ */
2875
+ function milliseconds(val: number): string;
2876
+ }
2877
+
2878
+ declare module "mocha/lib/interfaces/common" {
2879
+ export = common;
2880
+
2881
+ function common(suites: Mocha.Suite[], context: Mocha.MochaGlobals, mocha: Mocha): common.CommonFunctions;
2882
+
2883
+ namespace common {
2884
+ interface CommonFunctions {
2885
+ /**
2886
+ * This is only present if flag --delay is passed into Mocha. It triggers
2887
+ * root suite execution.
2888
+ */
2889
+ runWithSuite(suite: Mocha.Suite): () => void;
2890
+
2891
+ /**
2892
+ * Execute before running tests.
2893
+ */
2894
+ before(fn?: Mocha.Func | Mocha.AsyncFunc): void;
2895
+
2896
+ /**
2897
+ * Execute before running tests.
2898
+ */
2899
+ before(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void;
2900
+
2901
+ /**
2902
+ * Execute after running tests.
2903
+ */
2904
+ after(fn?: Mocha.Func | Mocha.AsyncFunc): void;
2905
+
2906
+ /**
2907
+ * Execute after running tests.
2908
+ */
2909
+ after(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void;
2910
+
2911
+ /**
2912
+ * Execute before each test case.
2913
+ */
2914
+ beforeEach(fn?: Mocha.Func | Mocha.AsyncFunc): void;
2915
+
2916
+ /**
2917
+ * Execute before each test case.
2918
+ */
2919
+ beforeEach(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void;
2920
+
2921
+ /**
2922
+ * Execute after each test case.
2923
+ */
2924
+ afterEach(fn?: Mocha.Func | Mocha.AsyncFunc): void;
2925
+
2926
+ /**
2927
+ * Execute after each test case.
2928
+ */
2929
+ afterEach(name: string, fn?: Mocha.Func | Mocha.AsyncFunc): void;
2930
+
2931
+ suite: SuiteFunctions;
2932
+ test: TestFunctions;
2933
+ }
2934
+
2935
+ interface CreateOptions {
2936
+ /** Title of suite */
2937
+ title: string;
2938
+
2939
+ /** Suite function */
2940
+ fn?: (this: Mocha.Suite) => void;
2941
+
2942
+ /** Is suite pending? */
2943
+ pending?: boolean;
2944
+
2945
+ /** Filepath where this Suite resides */
2946
+ file?: string;
2947
+
2948
+ /** Is suite exclusive? */
2949
+ isOnly?: boolean;
2950
+ }
2951
+
2952
+ interface SuiteFunctions {
2953
+ /**
2954
+ * Create an exclusive Suite; convenience function
2955
+ */
2956
+ only(opts: CreateOptions): Mocha.Suite;
2957
+
2958
+ /**
2959
+ * Create a Suite, but skip it; convenience function
2960
+ */
2961
+ skip(opts: CreateOptions): Mocha.Suite;
2962
+
2963
+ /**
2964
+ * Creates a suite.
2965
+ */
2966
+ create(opts: CreateOptions): Mocha.Suite;
2967
+ }
2968
+
2969
+ interface TestFunctions {
2970
+ /**
2971
+ * Exclusive test-case.
2972
+ */
2973
+ only(mocha: Mocha, test: Mocha.Test): Mocha.Test;
2974
+
2975
+ /**
2976
+ * Pending test case.
2977
+ */
2978
+ skip(title: string): void;
2979
+
2980
+ /**
2981
+ * Number of retry attempts
2982
+ */
2983
+ retries(n: number): void;
2984
+ }
2985
+ }
2986
+ }