From 70e16e45e10125c69d815ba3cf125f17f1c6e6c4 Mon Sep 17 00:00:00 2001 From: Christoph Nakazawa Date: Thu, 10 Aug 2017 16:24:20 +0100 Subject: [PATCH] Make jest-runner a standalone package. (#4236) --- packages/jest-cli/package.json | 5 +-- .../src/reporters/default_reporter.js | 3 +- packages/jest-cli/src/test_scheduler.js | 2 +- packages/jest-runner/.npmignore | 4 ++ packages/jest-runner/package.json | 22 ++++++++++ .../src/__tests__/test_runner.test.js | 4 +- .../src/index.js} | 2 +- .../{jest-cli => jest-runner}/src/run_test.js | 10 +++-- .../src/test_worker.js | 0 packages/jest-util/package.json | 1 + .../lib => jest-util/src}/buffered_console.js | 0 .../src}/get_console_output.js | 0 packages/jest-util/src/index.js | 8 +++- types/TestRunner.js | 4 +- yarn.lock | 40 ++++++++++++++----- 15 files changed, 78 insertions(+), 27 deletions(-) create mode 100644 packages/jest-runner/.npmignore create mode 100644 packages/jest-runner/package.json rename packages/{jest-cli => jest-runner}/src/__tests__/test_runner.test.js (96%) rename packages/{jest-cli/src/test_runner.js => jest-runner/src/index.js} (98%) rename packages/{jest-cli => jest-runner}/src/run_test.js (95%) rename packages/{jest-cli => jest-runner}/src/test_worker.js (100%) rename packages/{jest-cli/src/lib => jest-util/src}/buffered_console.js (100%) rename packages/{jest-cli/src/reporters => jest-util/src}/get_console_output.js (100%) diff --git a/packages/jest-cli/package.json b/packages/jest-cli/package.json index 7222d923ee61..8858da3ae588 100644 --- a/packages/jest-cli/package.json +++ b/packages/jest-cli/package.json @@ -5,7 +5,6 @@ "main": "build/jest.js", "dependencies": { "ansi-escapes": "^2.0.0", - "callsites": "^2.0.0", "chalk": "^2.0.1", "graceful-fs": "^4.1.11", "is-ci": "^1.0.10", @@ -15,13 +14,12 @@ "istanbul-lib-source-maps": "^1.1.0", "jest-changed-files": "^20.0.3", "jest-config": "^20.0.4", - "jest-docblock": "^20.0.3", "jest-environment-jsdom": "^20.0.3", "jest-haste-map": "^20.0.4", - "jest-jasmine2": "^20.0.4", "jest-message-util": "^20.0.3", "jest-regex-util": "^20.0.3", "jest-resolve-dependencies": "^20.0.3", + "jest-runner": "^20.0.4", "jest-runtime": "^20.0.4", "jest-snapshot": "^20.0.3", "jest-util": "^20.0.3", @@ -31,7 +29,6 @@ "slash": "^1.0.0", "string-length": "^1.0.1", "strip-ansi": "^4.0.0", - "throat": "^3.0.0", "which": "^1.2.12", "worker-farm": "^1.3.1", "yargs": "^7.0.2" diff --git a/packages/jest-cli/src/reporters/default_reporter.js b/packages/jest-cli/src/reporters/default_reporter.js index 2dca4d492c4a..08d4a9f24750 100644 --- a/packages/jest-cli/src/reporters/default_reporter.js +++ b/packages/jest-cli/src/reporters/default_reporter.js @@ -15,12 +15,11 @@ import type {GlobalConfig, Path, ProjectConfig} from 'types/Config'; import type {Test} from 'types/TestRunner'; import type {ReporterOnStartOptions} from 'types/Reporters'; -import {clearLine} from 'jest-util'; +import {clearLine, getConsoleOutput} from 'jest-util'; import chalk from 'chalk'; import isCI from 'is-ci'; import BaseReporter from './base_reporter'; import Status from './Status'; -import getConsoleOutput from './get_console_output'; import getResultHeader from './get_result_header'; type write = (chunk: string, enc?: any, cb?: () => void) => boolean; diff --git a/packages/jest-cli/src/test_scheduler.js b/packages/jest-cli/src/test_scheduler.js index 6d3a154e211a..6934a5e0d839 100644 --- a/packages/jest-cli/src/test_scheduler.js +++ b/packages/jest-cli/src/test_scheduler.js @@ -25,7 +25,7 @@ import NotifyReporter from './reporters/notify_reporter'; import ReporterDispatcher from './reporter_dispatcher'; import snapshot from 'jest-snapshot'; import SummaryReporter from './reporters/summary_reporter'; -import TestRunner from './test_runner'; +import TestRunner from 'jest-runner'; import TestWatcher from './test_watcher'; import VerboseReporter from './reporters/verbose_reporter'; diff --git a/packages/jest-runner/.npmignore b/packages/jest-runner/.npmignore new file mode 100644 index 000000000000..c8ab4c8d108a --- /dev/null +++ b/packages/jest-runner/.npmignore @@ -0,0 +1,4 @@ +**/__mocks__/** +**/__tests__/** +src +yarn.lock diff --git a/packages/jest-runner/package.json b/packages/jest-runner/package.json new file mode 100644 index 000000000000..fc4c05158a99 --- /dev/null +++ b/packages/jest-runner/package.json @@ -0,0 +1,22 @@ +{ + "name": "jest-runner", + "version": "20.0.4", + "repository": { + "type": "git", + "url": "https://github.com/facebook/jest.git" + }, + "license": "BSD-3-Clause", + "main": "build/index.js", + "dependencies": { + "jest-config": "^20.0.4", + "jest-docblock": "^20.0.3", + "jest-haste-map": "^20.0.4", + "jest-jasmine2": "^20.0.4", + "jest-message-util": "^20.0.3", + "jest-runtime": "^20.0.4", + "jest-util": "^20.0.3", + "pify": "^2.3.0", + "throat": "^3.0.0", + "worker-farm": "^1.3.1" + } +} diff --git a/packages/jest-cli/src/__tests__/test_runner.test.js b/packages/jest-runner/src/__tests__/test_runner.test.js similarity index 96% rename from packages/jest-cli/src/__tests__/test_runner.test.js rename to packages/jest-runner/src/__tests__/test_runner.test.js index d1c92012d902..94a6f29c517d 100644 --- a/packages/jest-cli/src/__tests__/test_runner.test.js +++ b/packages/jest-runner/src/__tests__/test_runner.test.js @@ -10,8 +10,8 @@ 'use strict'; -const TestRunner = require('../test_runner'); -const TestWatcher = require('../test_watcher'); +const TestRunner = require('../index'); +const {TestWatcher} = require('jest-cli'); let workerFarmMock; diff --git a/packages/jest-cli/src/test_runner.js b/packages/jest-runner/src/index.js similarity index 98% rename from packages/jest-cli/src/test_runner.js rename to packages/jest-runner/src/index.js index 3b4e8dcf5b9c..ecdb386f3f49 100644 --- a/packages/jest-cli/src/test_runner.js +++ b/packages/jest-runner/src/index.js @@ -9,13 +9,13 @@ */ import type {GlobalConfig} from 'types/Config'; -import type TestWatcher from './test_watcher'; import type { OnTestFailure, OnTestStart, OnTestSuccess, Test, TestRunnerOptions, + TestWatcher, } from 'types/TestRunner'; import pify from 'pify'; diff --git a/packages/jest-cli/src/run_test.js b/packages/jest-runner/src/run_test.js similarity index 95% rename from packages/jest-cli/src/run_test.js rename to packages/jest-runner/src/run_test.js index bdbe3e94404e..4c7fde3c18ca 100644 --- a/packages/jest-cli/src/run_test.js +++ b/packages/jest-runner/src/run_test.js @@ -16,11 +16,15 @@ import type {TestResult} from 'types/TestResult'; import type RuntimeClass from 'jest-runtime'; import fs from 'fs'; -import {Console, NullConsole, setGlobal} from 'jest-util'; +import { + BufferedConsole, + Console, + NullConsole, + getConsoleOutput, + setGlobal, +} from 'jest-util'; import {getTestEnvironment} from 'jest-config'; import docblock from 'jest-docblock'; -import BufferedConsole from './lib/buffered_console'; -import getConsoleOutput from './reporters/get_console_output'; function runTest( path: Path, diff --git a/packages/jest-cli/src/test_worker.js b/packages/jest-runner/src/test_worker.js similarity index 100% rename from packages/jest-cli/src/test_worker.js rename to packages/jest-runner/src/test_worker.js diff --git a/packages/jest-util/package.json b/packages/jest-util/package.json index 227bea5ccf9a..866c36a8a5d8 100644 --- a/packages/jest-util/package.json +++ b/packages/jest-util/package.json @@ -8,6 +8,7 @@ "license": "BSD-3-Clause", "main": "build/index.js", "dependencies": { + "callsites": "^2.0.0", "chalk": "^2.0.1", "graceful-fs": "^4.1.11", "jest-message-util": "^20.0.3", diff --git a/packages/jest-cli/src/lib/buffered_console.js b/packages/jest-util/src/buffered_console.js similarity index 100% rename from packages/jest-cli/src/lib/buffered_console.js rename to packages/jest-util/src/buffered_console.js diff --git a/packages/jest-cli/src/reporters/get_console_output.js b/packages/jest-util/src/get_console_output.js similarity index 100% rename from packages/jest-cli/src/reporters/get_console_output.js rename to packages/jest-util/src/get_console_output.js diff --git a/packages/jest-util/src/index.js b/packages/jest-util/src/index.js index a678191bd70b..72a3c1aa3013 100644 --- a/packages/jest-util/src/index.js +++ b/packages/jest-util/src/index.js @@ -10,12 +10,14 @@ import mkdirp from 'mkdirp'; +import BufferedConsole from './buffered_console'; +import clearLine from './clear_line'; import Console from './Console'; import FakeTimers from './fake_timers'; -import NullConsole from './null_console'; -import clearLine from './clear_line'; import formatTestResults from './format_test_results'; +import getConsoleOutput from './get_console_output'; import installCommonGlobals from './install_common_globals'; +import NullConsole from './null_console'; import setGlobal from './set_global'; import validateCLIOptions from './validate_cli_options'; @@ -30,12 +32,14 @@ const createDirectory = (path: string) => { }; module.exports = { + BufferedConsole, Console, FakeTimers, NullConsole, clearLine, createDirectory, formatTestResults, + getConsoleOutput, installCommonGlobals, setGlobal, validateCLIOptions, diff --git a/types/TestRunner.js b/types/TestRunner.js index 2a0aed75ea5c..2bce9e73e038 100644 --- a/types/TestRunner.js +++ b/types/TestRunner.js @@ -18,7 +18,7 @@ import type { TestResult, } from 'types/TestResult'; import type Runtime from 'jest-runtime'; -import type TestWatcher from 'jest-cli/src/test_watcher'; +import type {TestWatcher as _TestWatcher} from 'jest-cli'; export type Test = {| context: Context, @@ -26,6 +26,8 @@ export type Test = {| path: Path, |}; +export type TestWatcher = _TestWatcher; + export type OnTestStart = Test => Promise; export type OnTestFailure = (Test, SerializableError) => Promise<*>; export type OnTestSuccess = (Test, TestResult) => Promise<*>; diff --git a/yarn.lock b/yarn.lock index e0a61be4aa25..e55e9088654a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1815,6 +1815,14 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4: safe-buffer "^5.0.1" sha.js "^2.4.8" +create-react-class@^15.6.0: + version "15.6.0" + resolved "https://registry.yarnpkg.com/create-react-class/-/create-react-class-15.6.0.tgz#ab448497c26566e1e29413e883207d57cfe7bed4" + dependencies: + fbjs "^0.8.9" + loose-envify "^1.3.1" + object-assign "^4.1.1" + cross-spawn@^4.0.0: version "4.0.2" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-4.0.2.tgz#7b9247621c23adfdd3856004a823cbe397424d41" @@ -2607,7 +2615,7 @@ fb-watchman@^2.0.0: dependencies: bser "^2.0.0" -fbjs@^0.8.1, fbjs@^0.8.4, fbjs@^0.8.9: +fbjs@^0.8.4, fbjs@^0.8.9: version "0.8.12" resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.12.tgz#10b5d92f76d45575fd63a217d4ea02bea2f8ed04" dependencies: @@ -4104,7 +4112,7 @@ longest@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097" -loose-envify@^1.0.0, loose-envify@^1.1.0: +loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848" dependencies: @@ -4449,7 +4457,7 @@ object-assign@4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.0.tgz#7a3b3d0e98063d43f4c03f2e8ae6cd51a86883a0" -object-assign@^4.0.1, object-assign@^4.1.0: +object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" @@ -4814,6 +4822,13 @@ promise@^7.1.1: dependencies: asap "~2.0.3" +prop-types@^15.5.10: + version "15.5.10" + resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.5.10.tgz#2797dfc3126182e3a95e3dfbb2e893ddd7456154" + dependencies: + fbjs "^0.8.9" + loose-envify "^1.3.1" + prop-types@^15.5.4: version "15.5.8" resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.5.8.tgz#6b7b2e141083be38c8595aa51fc55775c7199394" @@ -4911,13 +4926,14 @@ react-deep-force-update@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/react-deep-force-update/-/react-deep-force-update-1.0.1.tgz#f911b5be1d2a6fe387507dd6e9a767aa2924b4c7" -react-dom@15.4.2: - version "15.4.2" - resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-15.4.2.tgz#015363f05b0a1fd52ae9efdd3a0060d90695208f" +react-dom@^15.6.1: + version "15.6.1" + resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-15.6.1.tgz#2cb0ed4191038e53c209eb3a79a23e2a4cf99470" dependencies: - fbjs "^0.8.1" + fbjs "^0.8.9" loose-envify "^1.1.0" object-assign "^4.1.0" + prop-types "^15.5.10" react-proxy@^1.1.7: version "1.1.8" @@ -4940,13 +4956,15 @@ react-transform-hmr@^1.0.4: global "^4.3.0" react-proxy "^1.1.7" -react@15.4.2: - version "15.4.2" - resolved "https://registry.yarnpkg.com/react/-/react-15.4.2.tgz#41f7991b26185392ba9bae96c8889e7e018397ef" +react@^15.4.2: + version "15.6.1" + resolved "https://registry.yarnpkg.com/react/-/react-15.6.1.tgz#baa8434ec6780bde997cdc380b79cd33b96393df" dependencies: - fbjs "^0.8.4" + create-react-class "^15.6.0" + fbjs "^0.8.9" loose-envify "^1.1.0" object-assign "^4.1.0" + prop-types "^15.5.10" read-cmd-shim@^1.0.1: version "1.0.1"