UNPKG

28.9 kBTypeScriptView Raw
1/**
2 * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7/// <reference types="node" />
8
9import type {Arguments} from 'yargs';
10import type {CoverageMapData} from 'istanbul-lib-coverage';
11import type {ForegroundColor} from 'chalk';
12import type {ReportOptions} from 'istanbul-reports';
13import type {SnapshotFormat} from '@jest/schemas';
14
15declare type Argv = Arguments<
16 Partial<{
17 all: boolean;
18 automock: boolean;
19 bail: boolean | number;
20 cache: boolean;
21 cacheDirectory: string;
22 changedFilesWithAncestor: boolean;
23 changedSince: string;
24 ci: boolean;
25 clearCache: boolean;
26 clearMocks: boolean;
27 collectCoverage: boolean;
28 collectCoverageFrom: string;
29 collectCoverageOnlyFrom: Array<string>;
30 color: boolean;
31 colors: boolean;
32 config: string;
33 coverage: boolean;
34 coverageDirectory: string;
35 coveragePathIgnorePatterns: Array<string>;
36 coverageReporters: Array<string>;
37 coverageThreshold: string;
38 debug: boolean;
39 env: string;
40 expand: boolean;
41 findRelatedTests: boolean;
42 forceExit: boolean;
43 globals: string;
44 globalSetup: string | null | undefined;
45 globalTeardown: string | null | undefined;
46 haste: string;
47 ignoreProjects: Array<string>;
48 init: boolean;
49 injectGlobals: boolean;
50 json: boolean;
51 lastCommit: boolean;
52 logHeapUsage: boolean;
53 maxWorkers: number | string;
54 moduleDirectories: Array<string>;
55 moduleFileExtensions: Array<string>;
56 moduleNameMapper: string;
57 modulePathIgnorePatterns: Array<string>;
58 modulePaths: Array<string>;
59 noStackTrace: boolean;
60 notify: boolean;
61 notifyMode: string;
62 onlyChanged: boolean;
63 onlyFailures: boolean;
64 outputFile: string;
65 preset: string | null | undefined;
66 prettierPath: string | null | undefined;
67 projects: Array<string>;
68 reporters: Array<string>;
69 resetMocks: boolean;
70 resetModules: boolean;
71 resolver: string | null | undefined;
72 restoreMocks: boolean;
73 rootDir: string;
74 roots: Array<string>;
75 runInBand: boolean;
76 selectProjects: Array<string>;
77 setupFiles: Array<string>;
78 setupFilesAfterEnv: Array<string>;
79 shard: string;
80 showConfig: boolean;
81 silent: boolean;
82 snapshotSerializers: Array<string>;
83 testEnvironment: string;
84 testEnvironmentOptions: string;
85 testFailureExitCode: string | null | undefined;
86 testMatch: Array<string>;
87 testNamePattern: string;
88 testPathIgnorePatterns: Array<string>;
89 testPathPattern: Array<string>;
90 testRegex: string | Array<string>;
91 testResultsProcessor: string;
92 testRunner: string;
93 testSequencer: string;
94 testTimeout: number | null | undefined;
95 transform: string;
96 transformIgnorePatterns: Array<string>;
97 unmockedModulePathPatterns: Array<string> | null | undefined;
98 updateSnapshot: boolean;
99 useStderr: boolean;
100 verbose: boolean;
101 version: boolean;
102 watch: boolean;
103 watchAll: boolean;
104 watchman: boolean;
105 watchPathIgnorePatterns: Array<string>;
106 }>
107>;
108
109declare type ArrayTable = Table | Row;
110
111declare type AssertionResult = {
112 ancestorTitles: Array<string>;
113 duration?: Milliseconds | null;
114 failureDetails: Array<unknown>;
115 failureMessages: Array<string>;
116 fullName: string;
117 invocations?: number;
118 location?: Callsite | null;
119 numPassingAsserts: number;
120 retryReasons?: Array<string>;
121 status: Status;
122 title: string;
123};
124
125declare type AsyncEvent =
126 | {
127 name: 'setup';
128 testNamePattern?: string;
129 runtimeGlobals: JestGlobals;
130 parentProcess: Process;
131 }
132 | {
133 name: 'include_test_location_in_result';
134 }
135 | {
136 name: 'hook_start';
137 hook: Hook;
138 }
139 | {
140 name: 'hook_success';
141 describeBlock?: DescribeBlock;
142 test?: TestEntry;
143 hook: Hook;
144 }
145 | {
146 name: 'hook_failure';
147 error: string | Exception;
148 describeBlock?: DescribeBlock;
149 test?: TestEntry;
150 hook: Hook;
151 }
152 | {
153 name: 'test_fn_start';
154 test: TestEntry;
155 }
156 | {
157 name: 'test_fn_success';
158 test: TestEntry;
159 }
160 | {
161 name: 'test_fn_failure';
162 error: Exception;
163 test: TestEntry;
164 }
165 | {
166 name: 'test_retry';
167 test: TestEntry;
168 }
169 | {
170 name: 'test_start';
171 test: TestEntry;
172 }
173 | {
174 name: 'test_skip';
175 test: TestEntry;
176 }
177 | {
178 name: 'test_todo';
179 test: TestEntry;
180 }
181 | {
182 name: 'test_done';
183 test: TestEntry;
184 }
185 | {
186 name: 'run_describe_start';
187 describeBlock: DescribeBlock;
188 }
189 | {
190 name: 'run_describe_finish';
191 describeBlock: DescribeBlock;
192 }
193 | {
194 name: 'run_start';
195 }
196 | {
197 name: 'run_finish';
198 }
199 | {
200 name: 'teardown';
201 };
202
203declare type AsyncFn = TestFn_2 | HookFn_2;
204
205declare type BlockFn = () => void;
206
207declare type BlockFn_2 = Global.BlockFn;
208
209declare type BlockMode = void | 'skip' | 'only' | 'todo';
210
211declare type BlockName = string;
212
213declare type BlockName_2 = Global.BlockName;
214
215declare type BlockNameLike = BlockName | NameLike;
216
217declare type BlockNameLike_2 = Global.BlockNameLike;
218
219declare type Callsite = {
220 column: number;
221 line: number;
222};
223
224declare namespace Circus {
225 export {
226 DoneFn,
227 BlockFn_2 as BlockFn,
228 BlockName_2 as BlockName,
229 BlockNameLike_2 as BlockNameLike,
230 BlockMode,
231 TestMode,
232 TestName_2 as TestName,
233 TestNameLike_2 as TestNameLike,
234 TestFn_2 as TestFn,
235 ConcurrentTestFn_2 as ConcurrentTestFn,
236 HookFn_2 as HookFn,
237 AsyncFn,
238 SharedHookType,
239 HookType,
240 TestContext_2 as TestContext,
241 Exception,
242 FormattedError,
243 Hook,
244 EventHandler,
245 Event_2 as Event,
246 SyncEvent,
247 AsyncEvent,
248 MatcherResults,
249 TestStatus,
250 TestResult_2 as TestResult,
251 RunResult,
252 TestResults,
253 GlobalErrorHandlers,
254 State,
255 DescribeBlock,
256 TestError,
257 TestEntry,
258 };
259}
260export {Circus};
261
262declare type Col = unknown;
263
264declare type ConcurrentTestFn = () => TestReturnValuePromise;
265
266declare type ConcurrentTestFn_2 = Global.ConcurrentTestFn;
267
268declare namespace Config {
269 export {
270 FakeableAPI,
271 GlobalFakeTimersConfig,
272 FakeTimersConfig,
273 LegacyFakeTimersConfig,
274 HasteConfig,
275 CoverageReporterName,
276 CoverageReporterWithOptions,
277 CoverageReporters,
278 ReporterConfig,
279 TransformerConfig,
280 ConfigGlobals,
281 DefaultOptions,
282 DisplayName,
283 InitialOptionsWithRootDir,
284 InitialProjectOptions,
285 InitialOptions,
286 SnapshotUpdateState,
287 CoverageThresholdValue,
288 GlobalConfig,
289 ProjectConfig,
290 Argv,
291 };
292}
293export {Config};
294
295declare interface ConfigGlobals {
296 [K: string]: unknown;
297}
298
299declare type CoverageProvider = 'babel' | 'v8';
300
301declare type CoverageReporterName = keyof ReportOptions;
302
303declare type CoverageReporters = Array<
304 CoverageReporterName | CoverageReporterWithOptions
305>;
306
307declare type CoverageReporterWithOptions<K = CoverageReporterName> =
308 K extends CoverageReporterName
309 ? ReportOptions[K] extends never
310 ? never
311 : [K, Partial<ReportOptions[K]>]
312 : never;
313
314declare type CoverageThreshold = {
315 [path: string]: CoverageThresholdValue;
316 global: CoverageThresholdValue;
317};
318
319declare type CoverageThresholdValue = {
320 branches?: number;
321 functions?: number;
322 lines?: number;
323 statements?: number;
324};
325
326declare type DefaultOptions = {
327 automock: boolean;
328 bail: number;
329 cache: boolean;
330 cacheDirectory: string;
331 changedFilesWithAncestor: boolean;
332 ci: boolean;
333 clearMocks: boolean;
334 collectCoverage: boolean;
335 coveragePathIgnorePatterns: Array<string>;
336 coverageReporters: Array<CoverageReporterName>;
337 coverageProvider: CoverageProvider;
338 detectLeaks: boolean;
339 detectOpenHandles: boolean;
340 errorOnDeprecated: boolean;
341 expand: boolean;
342 extensionsToTreatAsEsm: Array<string>;
343 fakeTimers: FakeTimers;
344 forceCoverageMatch: Array<string>;
345 globals: ConfigGlobals;
346 haste: HasteConfig;
347 injectGlobals: boolean;
348 listTests: boolean;
349 maxConcurrency: number;
350 maxWorkers: number | string;
351 moduleDirectories: Array<string>;
352 moduleFileExtensions: Array<string>;
353 moduleNameMapper: Record<string, string | Array<string>>;
354 modulePathIgnorePatterns: Array<string>;
355 noStackTrace: boolean;
356 notify: boolean;
357 notifyMode: NotifyMode;
358 passWithNoTests: boolean;
359 prettierPath: string;
360 resetMocks: boolean;
361 resetModules: boolean;
362 restoreMocks: boolean;
363 roots: Array<string>;
364 runTestsByPath: boolean;
365 runner: string;
366 setupFiles: Array<string>;
367 setupFilesAfterEnv: Array<string>;
368 skipFilter: boolean;
369 slowTestThreshold: number;
370 snapshotSerializers: Array<string>;
371 testEnvironment: string;
372 testEnvironmentOptions: Record<string, unknown>;
373 testFailureExitCode: string | number;
374 testLocationInResults: boolean;
375 testMatch: Array<string>;
376 testPathIgnorePatterns: Array<string>;
377 testRegex: Array<string>;
378 testRunner: string;
379 testSequencer: string;
380 transformIgnorePatterns: Array<string>;
381 useStderr: boolean;
382 watch: boolean;
383 watchPathIgnorePatterns: Array<string>;
384 watchman: boolean;
385};
386
387declare interface Describe extends DescribeBase {
388 only: DescribeBase;
389 skip: DescribeBase;
390}
391
392declare interface DescribeBase {
393 (blockName: BlockNameLike, blockFn: BlockFn): void;
394 each: Each<BlockFn>;
395}
396
397declare type DescribeBlock = {
398 type: 'describeBlock';
399 children: Array<DescribeBlock | TestEntry>;
400 hooks: Array<Hook>;
401 mode: BlockMode;
402 name: BlockName_2;
403 parent?: DescribeBlock;
404 /** @deprecated Please get from `children` array instead */
405 tests: Array<TestEntry>;
406};
407
408declare type DisplayName = {
409 name: string;
410 color: typeof ForegroundColor;
411};
412
413declare type DoneFn = Global.DoneFn;
414
415declare type DoneFn_2 = (reason?: string | Error) => void;
416
417declare type DoneTakingTestFn = (
418 this: TestContext,
419 done: DoneFn_2,
420) => ValidTestReturnValues;
421
422declare interface Each<EachFn extends TestFn | BlockFn> {
423 <T extends Record<string, unknown>>(table: ReadonlyArray<T>): (
424 name: string | NameLike,
425 fn: (arg: T) => ReturnType<EachFn>,
426 timeout?: number,
427 ) => void;
428 <T extends readonly [unknown, ...Array<unknown>]>(table: ReadonlyArray<T>): (
429 name: string | NameLike,
430 fn: (...args: T) => ReturnType<EachFn>,
431 timeout?: number,
432 ) => void;
433 <T extends readonly [unknown, ...Array<unknown>]>(table: T): (
434 name: string | NameLike,
435 fn: (...args: T) => ReturnType<EachFn>,
436 timeout?: number,
437 ) => void;
438 <T extends ReadonlyArray<unknown>>(table: ReadonlyArray<T>): (
439 name: string | NameLike,
440 fn: (...args: T) => ReturnType<EachFn>,
441 timeout?: number,
442 ) => void;
443 <T extends ReadonlyArray<unknown>>(table: T): (
444 name: string | NameLike,
445 fn: (...args: T) => ReturnType<EachFn>,
446 timeout?: number,
447 ) => void;
448 <T = unknown>(strings: TemplateStringsArray, ...expressions: Array<T>): (
449 name: string | NameLike,
450 fn: (arg: Record<string, T>) => ReturnType<EachFn>,
451 timeout?: number,
452 ) => void;
453 <T extends Record<string, unknown>>(
454 strings: TemplateStringsArray,
455 ...expressions: Array<unknown>
456 ): (
457 name: string | NameLike,
458 fn: (arg: T) => ReturnType<EachFn>,
459 timeout?: number,
460 ) => void;
461}
462
463declare type EachTable = ArrayTable | TemplateTable;
464
465declare type EachTestFn<EachCallback extends TestCallback> = (
466 ...args: ReadonlyArray<any>
467) => ReturnType<EachCallback>;
468
469declare type Event_2 = SyncEvent | AsyncEvent;
470
471declare interface EventHandler {
472 (event: AsyncEvent, state: State): void | Promise<void>;
473 (event: SyncEvent, state: State): void;
474}
475
476declare type Exception = any;
477
478declare type FakeableAPI =
479 | 'Date'
480 | 'hrtime'
481 | 'nextTick'
482 | 'performance'
483 | 'queueMicrotask'
484 | 'requestAnimationFrame'
485 | 'cancelAnimationFrame'
486 | 'requestIdleCallback'
487 | 'cancelIdleCallback'
488 | 'setImmediate'
489 | 'clearImmediate'
490 | 'setInterval'
491 | 'clearInterval'
492 | 'setTimeout'
493 | 'clearTimeout';
494
495declare type FakeTimers = GlobalFakeTimersConfig &
496 (
497 | (FakeTimersConfig & {
498 now?: Exclude<FakeTimersConfig['now'], Date>;
499 })
500 | LegacyFakeTimersConfig
501 );
502
503declare type FakeTimersConfig = {
504 /**
505 * If set to `true` all timers will be advanced automatically
506 * by 20 milliseconds every 20 milliseconds. A custom time delta
507 * may be provided by passing a number.
508 *
509 * @defaultValue
510 * The default is `false`.
511 */
512 advanceTimers?: boolean | number;
513 /**
514 * List of names of APIs (e.g. `Date`, `nextTick()`, `setImmediate()`,
515 * `setTimeout()`) that should not be faked.
516 *
517 * @defaultValue
518 * The default is `[]`, meaning all APIs are faked.
519 * */
520 doNotFake?: Array<FakeableAPI>;
521 /**
522 * Sets current system time to be used by fake timers.
523 *
524 * @defaultValue
525 * The default is `Date.now()`.
526 */
527 now?: number | Date;
528 /**
529 * The maximum number of recursive timers that will be run when calling
530 * `jest.runAllTimers()`.
531 *
532 * @defaultValue
533 * The default is `100_000` timers.
534 */
535 timerLimit?: number;
536 /**
537 * Use the old fake timers implementation instead of one backed by
538 * [`@sinonjs/fake-timers`](https://github.com/sinonjs/fake-timers).
539 *
540 * @defaultValue
541 * The default is `false`.
542 */
543 legacyFakeTimers?: false;
544};
545
546declare type FormattedError = string;
547
548declare type GeneratorReturningTestFn = (
549 this: TestContext,
550) => TestReturnValueGenerator;
551
552declare namespace Global {
553 export {
554 ValidTestReturnValues,
555 TestReturnValue,
556 TestContext,
557 DoneFn_2 as DoneFn,
558 DoneTakingTestFn,
559 PromiseReturningTestFn,
560 GeneratorReturningTestFn,
561 NameLike,
562 TestName,
563 TestNameLike,
564 TestFn,
565 ConcurrentTestFn,
566 BlockFn,
567 BlockName,
568 BlockNameLike,
569 HookFn,
570 Col,
571 Row,
572 Table,
573 ArrayTable,
574 TemplateTable,
575 TemplateData,
576 EachTable,
577 TestCallback,
578 EachTestFn,
579 HookBase,
580 ItBase,
581 It,
582 ItConcurrentBase,
583 ItConcurrentExtended,
584 ItConcurrent,
585 DescribeBase,
586 Describe,
587 TestFrameworkGlobals,
588 GlobalAdditions,
589 Global_2 as Global,
590 };
591}
592export {Global};
593
594declare interface Global_2
595 extends GlobalAdditions,
596 Omit<typeof globalThis, keyof GlobalAdditions> {
597 [extras: PropertyKey]: unknown;
598}
599
600declare interface GlobalAdditions extends TestFrameworkGlobals {
601 __coverage__: CoverageMapData;
602}
603
604declare type GlobalConfig = {
605 bail: number;
606 changedSince?: string;
607 changedFilesWithAncestor: boolean;
608 ci: boolean;
609 collectCoverage: boolean;
610 collectCoverageFrom: Array<string>;
611 collectCoverageOnlyFrom?: {
612 [key: string]: boolean;
613 };
614 coverageDirectory: string;
615 coveragePathIgnorePatterns?: Array<string>;
616 coverageProvider: CoverageProvider;
617 coverageReporters: CoverageReporters;
618 coverageThreshold?: CoverageThreshold;
619 detectLeaks: boolean;
620 detectOpenHandles: boolean;
621 expand: boolean;
622 filter?: string;
623 findRelatedTests: boolean;
624 forceExit: boolean;
625 json: boolean;
626 globalSetup?: string;
627 globalTeardown?: string;
628 lastCommit: boolean;
629 logHeapUsage: boolean;
630 listTests: boolean;
631 maxConcurrency: number;
632 maxWorkers: number;
633 noStackTrace: boolean;
634 nonFlagArgs: Array<string>;
635 noSCM?: boolean;
636 notify: boolean;
637 notifyMode: NotifyMode;
638 outputFile?: string;
639 onlyChanged: boolean;
640 onlyFailures: boolean;
641 passWithNoTests: boolean;
642 projects: Array<string>;
643 replname?: string;
644 reporters?: Array<ReporterConfig>;
645 runTestsByPath: boolean;
646 rootDir: string;
647 shard?: ShardConfig;
648 silent?: boolean;
649 skipFilter: boolean;
650 snapshotFormat: SnapshotFormat;
651 errorOnDeprecated: boolean;
652 testFailureExitCode: number;
653 testNamePattern?: string;
654 testPathPattern: string;
655 testResultsProcessor?: string;
656 testSequencer: string;
657 testTimeout?: number;
658 updateSnapshot: SnapshotUpdateState;
659 useStderr: boolean;
660 verbose?: boolean;
661 watch: boolean;
662 watchAll: boolean;
663 watchman: boolean;
664 watchPlugins?: Array<{
665 path: string;
666 config: Record<string, unknown>;
667 }> | null;
668};
669
670declare type GlobalErrorHandlers = {
671 uncaughtException: Array<(exception: Exception) => void>;
672 unhandledRejection: Array<
673 (exception: Exception, promise: Promise<unknown>) => void
674 >;
675};
676
677declare type GlobalFakeTimersConfig = {
678 /**
679 * Whether fake timers should be enabled globally for all test files.
680 *
681 * @defaultValue
682 * The default is `false`.
683 * */
684 enableGlobally?: boolean;
685};
686
687declare type HasteConfig = {
688 /** Whether to hash files using SHA-1. */
689 computeSha1?: boolean;
690 /** The platform to use as the default, e.g. 'ios'. */
691 defaultPlatform?: string | null;
692 /** Force use of Node's `fs` APIs rather than shelling out to `find` */
693 forceNodeFilesystemAPI?: boolean;
694 /**
695 * Whether to follow symlinks when crawling for files.
696 * This options cannot be used in projects which use watchman.
697 * Projects with `watchman` set to true will error if this option is set to true.
698 */
699 enableSymlinks?: boolean;
700 /** string to a custom implementation of Haste. */
701 hasteImplModulePath?: string;
702 /** All platforms to target, e.g ['ios', 'android']. */
703 platforms?: Array<string>;
704 /** Whether to throw on error on module collision. */
705 throwOnModuleCollision?: boolean;
706 /** Custom HasteMap module */
707 hasteMapModulePath?: string;
708 /** Whether to retain all files, allowing e.g. search for tests in `node_modules`. */
709 retainAllFiles?: boolean;
710};
711
712declare type Hook = {
713 asyncError: Error;
714 fn: HookFn_2;
715 type: HookType;
716 parent: DescribeBlock;
717 seenDone: boolean;
718 timeout: number | undefined | null;
719};
720
721declare interface HookBase {
722 (fn: HookFn, timeout?: number): void;
723}
724
725declare type HookFn = TestFn;
726
727declare type HookFn_2 = Global.HookFn;
728
729declare type HookType = SharedHookType | 'afterEach' | 'beforeEach';
730
731declare type InitialOptions = Partial<{
732 automock: boolean;
733 bail: boolean | number;
734 cache: boolean;
735 cacheDirectory: string;
736 ci: boolean;
737 clearMocks: boolean;
738 changedFilesWithAncestor: boolean;
739 changedSince: string;
740 collectCoverage: boolean;
741 collectCoverageFrom: Array<string>;
742 collectCoverageOnlyFrom: {
743 [key: string]: boolean;
744 };
745 coverageDirectory: string;
746 coveragePathIgnorePatterns: Array<string>;
747 coverageProvider: CoverageProvider;
748 coverageReporters: CoverageReporters;
749 coverageThreshold: CoverageThreshold;
750 dependencyExtractor: string;
751 detectLeaks: boolean;
752 detectOpenHandles: boolean;
753 displayName: string | DisplayName;
754 expand: boolean;
755 extensionsToTreatAsEsm: Array<string>;
756 fakeTimers: FakeTimers;
757 filter: string;
758 findRelatedTests: boolean;
759 forceCoverageMatch: Array<string>;
760 forceExit: boolean;
761 json: boolean;
762 globals: ConfigGlobals;
763 globalSetup: string | null | undefined;
764 globalTeardown: string | null | undefined;
765 haste: HasteConfig;
766 id: string;
767 injectGlobals: boolean;
768 reporters: Array<string | ReporterConfig>;
769 logHeapUsage: boolean;
770 lastCommit: boolean;
771 listTests: boolean;
772 maxConcurrency: number;
773 maxWorkers: number | string;
774 moduleDirectories: Array<string>;
775 moduleFileExtensions: Array<string>;
776 moduleNameMapper: {
777 [key: string]: string | Array<string>;
778 };
779 modulePathIgnorePatterns: Array<string>;
780 modulePaths: Array<string>;
781 noStackTrace: boolean;
782 notify: boolean;
783 notifyMode: string;
784 onlyChanged: boolean;
785 onlyFailures: boolean;
786 outputFile: string;
787 passWithNoTests: boolean;
788 preset: string | null | undefined;
789 prettierPath: string | null | undefined;
790 projects: Array<string | InitialProjectOptions>;
791 replname: string | null | undefined;
792 resetMocks: boolean;
793 resetModules: boolean;
794 resolver: string | null | undefined;
795 restoreMocks: boolean;
796 rootDir: string;
797 roots: Array<string>;
798 runner: string;
799 runTestsByPath: boolean;
800 runtime: string;
801 sandboxInjectedGlobals: Array<string>;
802 setupFiles: Array<string>;
803 setupFilesAfterEnv: Array<string>;
804 silent: boolean;
805 skipFilter: boolean;
806 skipNodeResolution: boolean;
807 slowTestThreshold: number;
808 snapshotResolver: string;
809 snapshotSerializers: Array<string>;
810 snapshotFormat: SnapshotFormat;
811 errorOnDeprecated: boolean;
812 testEnvironment: string;
813 testEnvironmentOptions: Record<string, unknown>;
814 testFailureExitCode: string | number;
815 testLocationInResults: boolean;
816 testMatch: Array<string>;
817 testNamePattern: string;
818 testPathIgnorePatterns: Array<string>;
819 testRegex: string | Array<string>;
820 testResultsProcessor: string;
821 testRunner: string;
822 testSequencer: string;
823 testTimeout: number;
824 transform: {
825 [regex: string]: string | TransformerConfig;
826 };
827 transformIgnorePatterns: Array<string>;
828 watchPathIgnorePatterns: Array<string>;
829 unmockedModulePathPatterns: Array<string>;
830 updateSnapshot: boolean;
831 useStderr: boolean;
832 verbose?: boolean;
833 watch: boolean;
834 watchAll: boolean;
835 watchman: boolean;
836 watchPlugins: Array<string | [string, Record<string, unknown>]>;
837}>;
838
839declare type InitialOptionsWithRootDir = InitialOptions &
840 Required<Pick<InitialOptions, 'rootDir'>>;
841
842declare type InitialProjectOptions = Pick<
843 InitialOptions & {
844 cwd?: string;
845 },
846 keyof ProjectConfig
847>;
848
849declare interface It extends ItBase {
850 only: ItBase;
851 skip: ItBase;
852 todo: (testName: TestNameLike) => void;
853}
854
855declare interface ItBase {
856 (testName: TestNameLike, fn: TestFn, timeout?: number): void;
857 each: Each<TestFn>;
858 failing(testName: TestNameLike, fn: TestFn, timeout?: number): void;
859}
860
861declare interface ItConcurrent extends It {
862 concurrent: ItConcurrentExtended;
863}
864
865declare interface ItConcurrentBase {
866 (testName: TestNameLike, testFn: ConcurrentTestFn, timeout?: number): void;
867 each: Each<ConcurrentTestFn>;
868 failing(testName: TestNameLike, fn: ConcurrentTestFn, timeout?: number): void;
869}
870
871declare interface ItConcurrentExtended extends ItConcurrentBase {
872 only: ItConcurrentBase;
873 skip: ItConcurrentBase;
874}
875
876declare interface JestGlobals extends Global.TestFrameworkGlobals {
877 expect: unknown;
878}
879
880declare type LegacyFakeTimersConfig = {
881 /**
882 * Use the old fake timers implementation instead of one backed by
883 * [`@sinonjs/fake-timers`](https://github.com/sinonjs/fake-timers).
884 *
885 * @defaultValue
886 * The default is `false`.
887 */
888 legacyFakeTimers?: true;
889};
890
891declare type MatcherResults = {
892 actual: unknown;
893 expected: unknown;
894 name: string;
895 pass: boolean;
896};
897
898declare type Milliseconds = number;
899
900declare type NameLike = number | Function;
901
902declare type NotifyMode =
903 | 'always'
904 | 'failure'
905 | 'success'
906 | 'change'
907 | 'success-change'
908 | 'failure-change';
909
910declare type Process = NodeJS.Process;
911
912declare type ProjectConfig = {
913 automock: boolean;
914 cache: boolean;
915 cacheDirectory: string;
916 clearMocks: boolean;
917 coveragePathIgnorePatterns: Array<string>;
918 cwd: string;
919 dependencyExtractor?: string;
920 detectLeaks: boolean;
921 detectOpenHandles: boolean;
922 displayName?: DisplayName;
923 errorOnDeprecated: boolean;
924 extensionsToTreatAsEsm: Array<string>;
925 fakeTimers: FakeTimers;
926 filter?: string;
927 forceCoverageMatch: Array<string>;
928 globalSetup?: string;
929 globalTeardown?: string;
930 globals: ConfigGlobals;
931 haste: HasteConfig;
932 id: string;
933 injectGlobals: boolean;
934 moduleDirectories: Array<string>;
935 moduleFileExtensions: Array<string>;
936 moduleNameMapper: Array<[string, string]>;
937 modulePathIgnorePatterns: Array<string>;
938 modulePaths?: Array<string>;
939 prettierPath: string;
940 resetMocks: boolean;
941 resetModules: boolean;
942 resolver?: string;
943 restoreMocks: boolean;
944 rootDir: string;
945 roots: Array<string>;
946 runner: string;
947 runtime?: string;
948 sandboxInjectedGlobals: Array<keyof typeof globalThis>;
949 setupFiles: Array<string>;
950 setupFilesAfterEnv: Array<string>;
951 skipFilter: boolean;
952 skipNodeResolution?: boolean;
953 slowTestThreshold: number;
954 snapshotResolver?: string;
955 snapshotSerializers: Array<string>;
956 snapshotFormat: SnapshotFormat;
957 testEnvironment: string;
958 testEnvironmentOptions: Record<string, unknown>;
959 testMatch: Array<string>;
960 testLocationInResults: boolean;
961 testPathIgnorePatterns: Array<string>;
962 testRegex: Array<string | RegExp>;
963 testRunner: string;
964 transform: Array<[string, string, Record<string, unknown>]>;
965 transformIgnorePatterns: Array<string>;
966 watchPathIgnorePatterns: Array<string>;
967 unmockedModulePathPatterns?: Array<string>;
968};
969
970declare type PromiseReturningTestFn = (this: TestContext) => TestReturnValue;
971
972declare type ReporterConfig = [string, Record<string, unknown>];
973
974declare type Row = ReadonlyArray<Col>;
975
976declare type RunResult = {
977 unhandledErrors: Array<FormattedError>;
978 testResults: TestResults;
979};
980
981declare type SerializableError = {
982 code?: unknown;
983 message: string;
984 stack: string | null | undefined;
985 type?: string;
986};
987
988declare type ShardConfig = {
989 shardIndex: number;
990 shardCount: number;
991};
992
993declare type SharedHookType = 'afterAll' | 'beforeAll';
994
995declare type SnapshotUpdateState = 'all' | 'new' | 'none';
996
997declare type State = {
998 currentDescribeBlock: DescribeBlock;
999 currentlyRunningTest?: TestEntry | null;
1000 expand?: boolean;
1001 hasFocusedTests: boolean;
1002 hasStarted: boolean;
1003 originalGlobalErrorHandlers?: GlobalErrorHandlers;
1004 parentProcess: Process | null;
1005 rootDescribeBlock: DescribeBlock;
1006 testNamePattern?: RegExp | null;
1007 testTimeout: number;
1008 unhandledErrors: Array<Exception>;
1009 includeTestLocationInResult: boolean;
1010 maxConcurrency: number;
1011};
1012
1013declare type Status =
1014 | 'passed'
1015 | 'failed'
1016 | 'skipped'
1017 | 'pending'
1018 | 'todo'
1019 | 'disabled';
1020
1021declare type SyncEvent =
1022 | {
1023 asyncError: Error;
1024 mode: BlockMode;
1025 name: 'start_describe_definition';
1026 blockName: BlockName_2;
1027 }
1028 | {
1029 mode: BlockMode;
1030 name: 'finish_describe_definition';
1031 blockName: BlockName_2;
1032 }
1033 | {
1034 asyncError: Error;
1035 name: 'add_hook';
1036 hookType: HookType;
1037 fn: HookFn_2;
1038 timeout: number | undefined;
1039 }
1040 | {
1041 asyncError: Error;
1042 name: 'add_test';
1043 testName: TestName_2;
1044 fn: TestFn_2;
1045 mode?: TestMode;
1046 concurrent: boolean;
1047 timeout: number | undefined;
1048 failing: boolean;
1049 }
1050 | {
1051 name: 'error';
1052 error: Exception;
1053 };
1054
1055declare type Table = ReadonlyArray<Row>;
1056
1057declare type TemplateData = ReadonlyArray<unknown>;
1058
1059declare type TemplateTable = TemplateStringsArray;
1060
1061declare type TestCallback = BlockFn | TestFn | ConcurrentTestFn;
1062
1063declare type TestContext = Record<string, unknown>;
1064
1065declare type TestContext_2 = Global.TestContext;
1066
1067declare type TestEntry = {
1068 type: 'test';
1069 asyncError: Exception;
1070 errors: Array<TestError>;
1071 retryReasons: Array<TestError>;
1072 fn: TestFn_2;
1073 invocations: number;
1074 mode: TestMode;
1075 concurrent: boolean;
1076 name: TestName_2;
1077 parent: DescribeBlock;
1078 startedAt?: number | null;
1079 duration?: number | null;
1080 seenDone: boolean;
1081 status?: TestStatus | null;
1082 timeout?: number;
1083 failing: boolean;
1084};
1085
1086declare type TestError = Exception | [Exception | undefined, Exception];
1087
1088declare type TestFn =
1089 | PromiseReturningTestFn
1090 | GeneratorReturningTestFn
1091 | DoneTakingTestFn;
1092
1093declare type TestFn_2 = Global.TestFn;
1094
1095declare interface TestFrameworkGlobals {
1096 it: ItConcurrent;
1097 test: ItConcurrent;
1098 fit: ItBase & {
1099 concurrent?: ItConcurrentBase;
1100 };
1101 xit: ItBase;
1102 xtest: ItBase;
1103 describe: Describe;
1104 xdescribe: DescribeBase;
1105 fdescribe: DescribeBase;
1106 beforeAll: HookBase;
1107 beforeEach: HookBase;
1108 afterEach: HookBase;
1109 afterAll: HookBase;
1110}
1111
1112declare type TestMode = BlockMode;
1113
1114declare type TestName = string;
1115
1116declare type TestName_2 = Global.TestName;
1117
1118declare type TestNameLike = TestName | NameLike;
1119
1120declare type TestNameLike_2 = Global.TestNameLike;
1121
1122declare namespace TestResult {
1123 export {Milliseconds, AssertionResult, SerializableError};
1124}
1125export {TestResult};
1126
1127declare type TestResult_2 = {
1128 duration?: number | null;
1129 errors: Array<FormattedError>;
1130 errorsDetailed: Array<MatcherResults | unknown>;
1131 invocations: number;
1132 status: TestStatus;
1133 location?: {
1134 column: number;
1135 line: number;
1136 } | null;
1137 retryReasons: Array<FormattedError>;
1138 testPath: Array<TestName_2 | BlockName_2>;
1139};
1140
1141declare type TestResults = Array<TestResult_2>;
1142
1143declare type TestReturnValue = ValidTestReturnValues | TestReturnValuePromise;
1144
1145declare type TestReturnValueGenerator = Generator<void, unknown, void>;
1146
1147declare type TestReturnValuePromise = Promise<unknown>;
1148
1149declare type TestStatus = 'skip' | 'done' | 'todo';
1150
1151declare type TransformerConfig = [string, Record<string, unknown>];
1152
1153declare type TransformResult = {
1154 code: string;
1155 originalCode: string;
1156 sourceMapPath: string | null;
1157};
1158
1159declare namespace TransformTypes {
1160 export {TransformResult};
1161}
1162export {TransformTypes};
1163
1164declare type ValidTestReturnValues = void | undefined;
1165
1166export {};