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

Fix missing console log output in verbose mode #6871

Merged
merged 10 commits into from Dec 18, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -45,6 +45,7 @@
- `[jest-haste-map]` [**BREAKING**] Recover files correctly after haste name collisions are fixed ([#7329](https://github.com/facebook/jest/pull/7329))
- `[pretty-format]` [**BREAKING**] Omit non-enumerable symbol properties ([#7448](https://github.com/facebook/jest/pull/7448))
- `[*]` [**BREAKING**] Upgrade to Babel 7, dropping support for Babel 6 ([#7016](https://github.com/facebook/jest/pull/7016))
- `[jest-runner/jest-worker]` Fix missing console output in verbose mode ([#6871](https://github.com/facebook/jest/pull/6871))
- `[expect]` Standardize file naming in `expect` ([#7306](https://github.com/facebook/jest/pull/7306))
- `[jest-each]` Add empty array validation check ([#7249](https://github.com/facebook/jest/pull/7249))
- `[jest-cli]` Interrupt tests if interactive watch plugin key is pressed ([#7222](https://github.com/facebook/jest/pull/7222))
Expand Down
5 changes: 0 additions & 5 deletions package.json
Expand Up @@ -97,11 +97,6 @@
"packages/*",
"website",
"examples/*"
],
"nohoist": [
"**/react-native",
"**/react-native/**",
"examples/react-native/**"
]
},
"prettier": {
Expand Down
5 changes: 4 additions & 1 deletion packages/jest-runner/src/index.js
Expand Up @@ -97,11 +97,14 @@ class TestRunner {
// $FlowFixMe: class object is augmented with worker when instantiating.
const worker: WorkerInterface = new Worker(TEST_WORKER_PATH, {
exposedMethods: ['worker'],
forkOptions: {stdio: 'inherit'},
forkOptions: {stdio: 'pipe'},
maxRetries: 3,
numWorkers: this._globalConfig.maxWorkers,
});

if (worker.getStdout()) worker.getStdout().pipe(process.stdout);
if (worker.getStderr()) worker.getStderr().pipe(process.stderr);

const mutex = throat(this._globalConfig.maxWorkers);

// Send test suites to workers continuously instead of all at once to track
Expand Down
3 changes: 2 additions & 1 deletion packages/jest-worker/package.json
Expand Up @@ -8,7 +8,8 @@
"license": "MIT",
"main": "build/index.js",
"dependencies": {
"merge-stream": "^1.0.1"
"merge-stream": "^1.0.1",
"supports-color": "^5.5.0"
},
"engines": {
"node": ">= 6"
Expand Down
14 changes: 11 additions & 3 deletions packages/jest-worker/src/workers/ChildProcessWorker.js
Expand Up @@ -24,6 +24,8 @@ import type {Readable} from 'stream';

import type {ChildMessage, OnEnd, OnStart, WorkerOptions} from '../types';

import supportsColor from 'supports-color';

/**
* This class wraps the child process and provides a nice interface to
* communicate with. It takes care of:
Expand Down Expand Up @@ -54,15 +56,21 @@ export default class ChildProcessWorker implements WorkerInterface {
}

initialize() {
const forceColor = supportsColor.stdout ? {FORCE_COLOR: '1'} : {};
const child = childProcess.fork(
require.resolve('./processChild'),
// $FlowFixMe: Flow does not work well with Object.assign.
Object.assign(
{
cwd: process.cwd(),
env: Object.assign({}, process.env, {
JEST_WORKER_ID: this._options.workerId,
}),
env: Object.assign(
{},
process.env,
{
JEST_WORKER_ID: this._options.workerId,
},
forceColor,
),
// Suppress --debug / --inspect flags while preserving others (like --harmony).
execArgv: process.execArgv.filter(v => !/^--(debug|inspect)/.test(v)),
silent: true,
Expand Down
Expand Up @@ -10,6 +10,7 @@
/* eslint-disable no-new */

import EventEmitter from 'events';
import supportsColor from 'supports-color';

import {
CHILD_MESSAGE_CALL,
Expand Down Expand Up @@ -64,7 +65,9 @@ it('passes fork options down to child_process.fork, adding the defaults', () =>
expect(childProcess.fork.mock.calls[0][0]).toBe(child);
expect(childProcess.fork.mock.calls[0][1]).toEqual({
cwd: '/tmp', // Overridden default option.
env: process.env, // Default option.
env: Object.assign({}, process.env, {
FORCE_COLOR: supportsColor.stdout ? '1' : undefined,
}), // Default option.
execArgv: ['-p'], // Filtered option.
execPath: 'hello', // Added option.
silent: true, // Default option.
Expand Down