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