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