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