1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | import {Config} from '@jest/types';
|
8 | import type {SerializableError} from '@jest/test-result';
|
9 | import {Test} from '@jest/test-result';
|
10 | import {TestEvents} from '@jest/test-result';
|
11 | import type {TestResult} from '@jest/test-result';
|
12 | import {TestWatcher} from 'jest-watcher';
|
13 |
|
14 | declare abstract class BaseTestRunner {
|
15 | protected readonly _globalConfig: Config.GlobalConfig;
|
16 | protected readonly _context: TestRunnerContext;
|
17 | readonly isSerial?: boolean;
|
18 | abstract readonly supportsEventEmitters: boolean;
|
19 | constructor(_globalConfig: Config.GlobalConfig, _context: TestRunnerContext);
|
20 | }
|
21 |
|
22 | export declare abstract class CallbackTestRunner
|
23 | extends BaseTestRunner
|
24 | implements CallbackTestRunnerInterface
|
25 | {
|
26 | readonly supportsEventEmitters = false;
|
27 | abstract runTests(
|
28 | tests: Array<Test>,
|
29 | watcher: TestWatcher,
|
30 | onStart: OnTestStart,
|
31 | onResult: OnTestSuccess,
|
32 | onFailure: OnTestFailure,
|
33 | options: TestRunnerOptions,
|
34 | ): Promise<void>;
|
35 | }
|
36 |
|
37 | export declare interface CallbackTestRunnerInterface {
|
38 | readonly isSerial?: boolean;
|
39 | readonly supportsEventEmitters?: boolean;
|
40 | runTests(
|
41 | tests: Array<Test>,
|
42 | watcher: TestWatcher,
|
43 | onStart: OnTestStart,
|
44 | onResult: OnTestSuccess,
|
45 | onFailure: OnTestFailure,
|
46 | options: TestRunnerOptions,
|
47 | ): Promise<void>;
|
48 | }
|
49 |
|
50 | export {Config};
|
51 |
|
52 | export declare abstract class EmittingTestRunner
|
53 | extends BaseTestRunner
|
54 | implements EmittingTestRunnerInterface
|
55 | {
|
56 | readonly supportsEventEmitters = true;
|
57 | abstract runTests(
|
58 | tests: Array<Test>,
|
59 | watcher: TestWatcher,
|
60 | options: TestRunnerOptions,
|
61 | ): Promise<void>;
|
62 | abstract on<Name extends keyof TestEvents>(
|
63 | eventName: Name,
|
64 | listener: (eventData: TestEvents[Name]) => void | Promise<void>,
|
65 | ): UnsubscribeFn;
|
66 | }
|
67 |
|
68 | export declare interface EmittingTestRunnerInterface {
|
69 | readonly isSerial?: boolean;
|
70 | readonly supportsEventEmitters: true;
|
71 | runTests(
|
72 | tests: Array<Test>,
|
73 | watcher: TestWatcher,
|
74 | options: TestRunnerOptions,
|
75 | ): Promise<void>;
|
76 | on<Name extends keyof TestEvents>(
|
77 | eventName: Name,
|
78 | listener: (eventData: TestEvents[Name]) => void | Promise<void>,
|
79 | ): UnsubscribeFn;
|
80 | }
|
81 |
|
82 | export declare type JestTestRunner = CallbackTestRunner | EmittingTestRunner;
|
83 |
|
84 | export declare type OnTestFailure = (
|
85 | test: Test,
|
86 | serializableError: SerializableError,
|
87 | ) => Promise<void>;
|
88 |
|
89 | export declare type OnTestStart = (test: Test) => Promise<void>;
|
90 |
|
91 | export declare type OnTestSuccess = (
|
92 | test: Test,
|
93 | testResult: TestResult,
|
94 | ) => Promise<void>;
|
95 |
|
96 | export {Test};
|
97 |
|
98 | export {TestEvents};
|
99 |
|
100 | declare class TestRunner extends EmittingTestRunner {
|
101 | #private;
|
102 | runTests(
|
103 | tests: Array<Test>,
|
104 | watcher: TestWatcher,
|
105 | options: TestRunnerOptions,
|
106 | ): Promise<void>;
|
107 | on<Name extends keyof TestEvents>(
|
108 | eventName: Name,
|
109 | listener: (eventData: TestEvents[Name]) => void | Promise<void>,
|
110 | ): UnsubscribeFn;
|
111 | }
|
112 | export default TestRunner;
|
113 |
|
114 | export declare type TestRunnerContext = {
|
115 | changedFiles?: Set<string>;
|
116 | sourcesRelatedToTestsInChangedFiles?: Set<string>;
|
117 | };
|
118 |
|
119 | export declare type TestRunnerOptions = {
|
120 | serial: boolean;
|
121 | };
|
122 |
|
123 | export {TestWatcher};
|
124 |
|
125 | export declare type UnsubscribeFn = () => void;
|
126 |
|
127 | export {};
|