Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export necessary types from jest-runner #8825

Merged
merged 2 commits into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- `[@jest-transform]` Extract transforming require logic within `jest-core` into `@jest-transform` ([#8756](https://github.com/facebook/jest/pull/8756))
- `[jest-matcher-utils]` Add color options to `matcherHint` ([#8795](https://github.com/facebook/jest/pull/8795))
- `[jest-circus/jest-jasmine2]` Give clearer output for Node assert errors ([#8792](https://github.com/facebook/jest/pull/8792))
- `[jest-runner]` Export all types in the type signature of `jest-runner` ([#8825](https://github.com/facebook/jest/pull/8825))`

### Fixes

Expand Down
51 changes: 30 additions & 21 deletions packages/jest-runner/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import Worker from 'jest-worker';
import runTest from './runTest';
import {worker, SerializableResolver} from './testWorker';
import {
OnTestFailure,
OnTestStart,
OnTestSuccess,
OnTestFailure as JestOnTestFailure,
OnTestStart as JestOnTestStart,
OnTestSuccess as JestOnTestSuccess,
Test as JestTest,
TestRunnerContext,
TestRunnerOptions,
TestWatcher,
TestRunnerContext as JestTestRunnerContext,
TestRunnerOptions as JestTestRunnerOptions,
TestWatcher as JestTestWatcher,
WatcherState,
} from './types';

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

namespace TestRunner {
export type Test = JestTest;
export type OnTestFailure = JestOnTestFailure;
export type OnTestStart = JestOnTestStart;
export type OnTestSuccess = JestOnTestSuccess;
export type TestWatcher = JestTestWatcher;
export type TestRunnerContext = JestTestRunnerContext;
export type TestRunnerOptions = JestTestRunnerOptions;
}

/* eslint-disable-next-line no-redeclare */
class TestRunner {
private _globalConfig: Config.GlobalConfig;
private _context: TestRunnerContext;
private _context: JestTestRunnerContext;

constructor(globalConfig: Config.GlobalConfig, context?: TestRunnerContext) {
constructor(
globalConfig: Config.GlobalConfig,
context?: JestTestRunnerContext,
) {
this._globalConfig = globalConfig;
this._context = context || {};
}

async runTests(
tests: Array<JestTest>,
watcher: TestWatcher,
onStart: OnTestStart,
onResult: OnTestSuccess,
onFailure: OnTestFailure,
options: TestRunnerOptions,
watcher: JestTestWatcher,
onStart: JestOnTestStart,
onResult: JestOnTestSuccess,
onFailure: JestOnTestFailure,
options: JestTestRunnerOptions,
): Promise<void> {
return await (options.serial
? this._createInBandTestRun(tests, watcher, onStart, onResult, onFailure)
Expand All @@ -64,10 +73,10 @@ class TestRunner {

private async _createInBandTestRun(
tests: Array<JestTest>,
watcher: TestWatcher,
onStart: OnTestStart,
onResult: OnTestSuccess,
onFailure: OnTestFailure,
watcher: JestTestWatcher,
onStart: JestOnTestStart,
onResult: JestOnTestSuccess,
onFailure: JestOnTestFailure,
) {
process.env.JEST_WORKER_ID = '1';
const mutex = throat(1);
Expand Down Expand Up @@ -98,10 +107,10 @@ class TestRunner {

private async _createParallelTestRun(
tests: Array<JestTest>,
watcher: TestWatcher,
onStart: OnTestStart,
onResult: OnTestSuccess,
onFailure: OnTestFailure,
watcher: JestTestWatcher,
onStart: JestOnTestStart,
onResult: JestOnTestSuccess,
onFailure: JestOnTestFailure,
) {
const resolvers: Map<string, SerializableResolver> = new Map();
for (const test of tests) {
Expand Down