UNPKG

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