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