UNPKG

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