Skip to content

Commit

Permalink
chore: export types from jest-runner (#8825)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark1626 authored and SimenB committed Aug 15, 2019
1 parent d610c9a commit 3ab2fc1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
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

0 comments on commit 3ab2fc1

Please sign in to comment.