Skip to content

Commit 3ab2fc1

Browse files
Mark1626SimenB
authored andcommitted
chore: export types from jest-runner (#8825)
1 parent d610c9a commit 3ab2fc1

File tree

2 files changed

+31
-21
lines changed

2 files changed

+31
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
- `[@jest-transform]` Extract transforming require logic within `jest-core` into `@jest-transform` ([#8756](https://github.com/facebook/jest/pull/8756))
2626
- `[jest-matcher-utils]` Add color options to `matcherHint` ([#8795](https://github.com/facebook/jest/pull/8795))
2727
- `[jest-circus/jest-jasmine2]` Give clearer output for Node assert errors ([#8792](https://github.com/facebook/jest/pull/8792))
28+
- `[jest-runner]` Export all types in the type signature of `jest-runner` ([#8825](https://github.com/facebook/jest/pull/8825))`
2829

2930
### Fixes
3031

packages/jest-runner/src/index.ts

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import Worker from 'jest-worker';
1313
import runTest from './runTest';
1414
import {worker, SerializableResolver} from './testWorker';
1515
import {
16-
OnTestFailure,
17-
OnTestStart,
18-
OnTestSuccess,
16+
OnTestFailure as JestOnTestFailure,
17+
OnTestStart as JestOnTestStart,
18+
OnTestSuccess as JestOnTestSuccess,
1919
Test as JestTest,
20-
TestRunnerContext,
21-
TestRunnerOptions,
22-
TestWatcher,
20+
TestRunnerContext as JestTestRunnerContext,
21+
TestRunnerOptions as JestTestRunnerOptions,
22+
TestWatcher as JestTestWatcher,
2323
WatcherState,
2424
} from './types';
2525

@@ -31,25 +31,34 @@ interface WorkerInterface extends Worker {
3131

3232
namespace TestRunner {
3333
export type Test = JestTest;
34+
export type OnTestFailure = JestOnTestFailure;
35+
export type OnTestStart = JestOnTestStart;
36+
export type OnTestSuccess = JestOnTestSuccess;
37+
export type TestWatcher = JestTestWatcher;
38+
export type TestRunnerContext = JestTestRunnerContext;
39+
export type TestRunnerOptions = JestTestRunnerOptions;
3440
}
3541

3642
/* eslint-disable-next-line no-redeclare */
3743
class TestRunner {
3844
private _globalConfig: Config.GlobalConfig;
39-
private _context: TestRunnerContext;
45+
private _context: JestTestRunnerContext;
4046

41-
constructor(globalConfig: Config.GlobalConfig, context?: TestRunnerContext) {
47+
constructor(
48+
globalConfig: Config.GlobalConfig,
49+
context?: JestTestRunnerContext,
50+
) {
4251
this._globalConfig = globalConfig;
4352
this._context = context || {};
4453
}
4554

4655
async runTests(
4756
tests: Array<JestTest>,
48-
watcher: TestWatcher,
49-
onStart: OnTestStart,
50-
onResult: OnTestSuccess,
51-
onFailure: OnTestFailure,
52-
options: TestRunnerOptions,
57+
watcher: JestTestWatcher,
58+
onStart: JestOnTestStart,
59+
onResult: JestOnTestSuccess,
60+
onFailure: JestOnTestFailure,
61+
options: JestTestRunnerOptions,
5362
): Promise<void> {
5463
return await (options.serial
5564
? this._createInBandTestRun(tests, watcher, onStart, onResult, onFailure)
@@ -64,10 +73,10 @@ class TestRunner {
6473

6574
private async _createInBandTestRun(
6675
tests: Array<JestTest>,
67-
watcher: TestWatcher,
68-
onStart: OnTestStart,
69-
onResult: OnTestSuccess,
70-
onFailure: OnTestFailure,
76+
watcher: JestTestWatcher,
77+
onStart: JestOnTestStart,
78+
onResult: JestOnTestSuccess,
79+
onFailure: JestOnTestFailure,
7180
) {
7281
process.env.JEST_WORKER_ID = '1';
7382
const mutex = throat(1);
@@ -98,10 +107,10 @@ class TestRunner {
98107

99108
private async _createParallelTestRun(
100109
tests: Array<JestTest>,
101-
watcher: TestWatcher,
102-
onStart: OnTestStart,
103-
onResult: OnTestSuccess,
104-
onFailure: OnTestFailure,
110+
watcher: JestTestWatcher,
111+
onStart: JestOnTestStart,
112+
onResult: JestOnTestSuccess,
113+
onFailure: JestOnTestFailure,
105114
) {
106115
const resolvers: Map<string, SerializableResolver> = new Map();
107116
for (const test of tests) {

0 commit comments

Comments
 (0)