From 00ddfde74ddbf65f1d0ee19655519cdbd16e2469 Mon Sep 17 00:00:00 2001 From: M4rk9696 Date: Thu, 15 Aug 2019 00:41:23 +0530 Subject: [PATCH 1/2] chore: Export types from jest-runner --- packages/jest-runner/src/index.ts | 51 ++++++++++++++++++------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/packages/jest-runner/src/index.ts b/packages/jest-runner/src/index.ts index 7cfdbc1fc7c7..c64e658bae98 100644 --- a/packages/jest-runner/src/index.ts +++ b/packages/jest-runner/src/index.ts @@ -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'; @@ -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, - watcher: TestWatcher, - onStart: OnTestStart, - onResult: OnTestSuccess, - onFailure: OnTestFailure, - options: TestRunnerOptions, + watcher: JestTestWatcher, + onStart: JestOnTestStart, + onResult: JestOnTestSuccess, + onFailure: JestOnTestFailure, + options: JestTestRunnerOptions, ): Promise { return await (options.serial ? this._createInBandTestRun(tests, watcher, onStart, onResult, onFailure) @@ -64,10 +73,10 @@ class TestRunner { private async _createInBandTestRun( tests: Array, - 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); @@ -98,10 +107,10 @@ class TestRunner { private async _createParallelTestRun( tests: Array, - watcher: TestWatcher, - onStart: OnTestStart, - onResult: OnTestSuccess, - onFailure: OnTestFailure, + watcher: JestTestWatcher, + onStart: JestOnTestStart, + onResult: JestOnTestSuccess, + onFailure: JestOnTestFailure, ) { const resolvers: Map = new Map(); for (const test of tests) { From 679d7b2b386e9548ebf4877b530bdccb81beb809 Mon Sep 17 00:00:00 2001 From: M4rk9696 Date: Thu, 15 Aug 2019 08:30:11 +0530 Subject: [PATCH 2/2] docs: Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 462ef8d981c9..7770f1e6d1b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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