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