From 533885b10f0e19c1b9a1fdfefc69d0e7c185266d Mon Sep 17 00:00:00 2001 From: cpojer Date: Wed, 3 May 2017 08:14:46 +0100 Subject: [PATCH] Fixes. --- docs/en/CLI.md | 2 +- packages/jest-cli/src/cli/runCLI.js | 4 +++- packages/jest-cli/src/runJest.js | 11 +++++------ packages/jest-config/src/index.js | 1 - packages/jest-config/src/normalize.js | 1 - packages/jest-config/src/validConfig.js | 1 - .../src/__tests__/fixtures/jestConfig.js | 1 - types/Config.js | 1 - 8 files changed, 9 insertions(+), 13 deletions(-) diff --git a/docs/en/CLI.md b/docs/en/CLI.md index 686a958b494d..b46d556b9c25 100644 --- a/docs/en/CLI.md +++ b/docs/en/CLI.md @@ -135,7 +135,7 @@ Will run all tests affected by file changes in the last commit made. ### `--listTests` -Lists all tests Jest will run given the other arguments, and exits. +Lists all tests as JSON that Jest will run given the arguments, and exits. This can be used together with `--findRelatedTests` to know which tests Jest will run. ### `--logHeapUsage` diff --git a/packages/jest-cli/src/cli/runCLI.js b/packages/jest-cli/src/cli/runCLI.js index cbe8643766d6..101e4a001b6f 100644 --- a/packages/jest-cli/src/cli/runCLI.js +++ b/packages/jest-cli/src/cli/runCLI.js @@ -75,7 +75,9 @@ module.exports = async ( return watch(globalConfig, contexts, argv, pipe, hasteMapInstances); } else { const startRun = () => { - preRunMessage.print(pipe); + if (!argv.listTests) { + preRunMessage.print(pipe); + } runJest( globalConfig, contexts, diff --git a/packages/jest-cli/src/runJest.js b/packages/jest-cli/src/runJest.js index 968a65301099..a6824f4f5f9e 100644 --- a/packages/jest-cli/src/runJest.js +++ b/packages/jest-cli/src/runJest.js @@ -154,7 +154,7 @@ const runJest = async ( pipe: stream$Writable | tty$WriteStream, testWatcher: TestWatcher, startRun: () => *, - onComplete: (testResults: any) => void, + onComplete: (testResults: any) => any, ) => { const maxWorkers = getMaxWorkers(argv); const pattern = getTestPathPattern(argv); @@ -176,11 +176,10 @@ const runJest = async ( allTests = sequencer.sort(allTests); - // With --listTests, simply print the test info as JSON and exit. - if (globalConfig.listTests) { - const testsJson = JSON.stringify(allTests, null, ' '); - new Console(pipe, pipe).log(testsJson); - process.exit(0); + if (argv.listTests) { + console.log(JSON.stringify(allTests.map(test => test.path))); + onComplete && onComplete({success: true}); + return null; } if (!allTests.length) { diff --git a/packages/jest-config/src/index.js b/packages/jest-config/src/index.js index 68145bbfcc2b..9e3d1b808d77 100644 --- a/packages/jest-config/src/index.js +++ b/packages/jest-config/src/index.js @@ -69,7 +69,6 @@ const getConfigs = ( coverageThreshold: options.coverageThreshold, expand: options.expand, forceExit: options.forceExit, - listTests: options.listTests, logHeapUsage: options.logHeapUsage, mapCoverage: options.mapCoverage, noStackTrace: options.noStackTrace, diff --git a/packages/jest-config/src/normalize.js b/packages/jest-config/src/normalize.js index 606b967407a2..05813f54f961 100644 --- a/packages/jest-config/src/normalize.js +++ b/packages/jest-config/src/normalize.js @@ -376,7 +376,6 @@ function normalize(options: InitialOptions, argv: Object = {}) { case 'coverageThreshold': case 'expand': case 'globals': - case 'listTests': case 'logHeapUsage': case 'mapCoverage': case 'moduleDirectories': diff --git a/packages/jest-config/src/validConfig.js b/packages/jest-config/src/validConfig.js index 55a977edd812..67f4a3ca014a 100644 --- a/packages/jest-config/src/validConfig.js +++ b/packages/jest-config/src/validConfig.js @@ -43,7 +43,6 @@ module.exports = ({ haste: { providesModuleNodeModules: ['react', 'react-native'], }, - listTests: false, logHeapUsage: true, mapCoverage: false, moduleDirectories: ['node_modules'], diff --git a/packages/jest-validate/src/__tests__/fixtures/jestConfig.js b/packages/jest-validate/src/__tests__/fixtures/jestConfig.js index de401153c11a..3b7d3757e57b 100644 --- a/packages/jest-validate/src/__tests__/fixtures/jestConfig.js +++ b/packages/jest-validate/src/__tests__/fixtures/jestConfig.js @@ -85,7 +85,6 @@ const validConfig = { haste: { providesModuleNodeModules: ['react', 'react-native'], }, - listTests: true, logHeapUsage: true, moduleDirectories: ['node_modules'], moduleFileExtensions: ['js', 'json', 'jsx', 'node'], diff --git a/types/Config.js b/types/Config.js index 0423a3883ee9..24df602ee164 100644 --- a/types/Config.js +++ b/types/Config.js @@ -134,7 +134,6 @@ export type GlobalConfig = {| coverageThreshold: {global: {[key: string]: number}}, expand: boolean, forceExit: boolean, - listTests: boolean, logHeapUsage: boolean, mapCoverage: boolean, noStackTrace: boolean,