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 8 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 @@ -35,6 +35,7 @@

### Fixes

- `[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: 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
1 change: 1 addition & 0 deletions packages/jest-worker/package.json
Expand Up @@ -8,6 +8,7 @@
"license": "MIT",
"main": "build/index.js",
"dependencies": {
"supports-color": "^5.5.0",
"merge-stream": "^1.0.1"
},
"engines": {
Expand Down
14 changes: 11 additions & 3 deletions packages/jest-worker/src/Worker.js
Expand Up @@ -29,6 +29,8 @@ import type {
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 @@ -88,15 +90,21 @@ export default class {
}

_initialize() {
const forceColor = supportsColor.stdout ? {FORCE_COLOR: '1'} : {};
const child = childProcess.fork(
require.resolve('./child'),
// $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
5 changes: 4 additions & 1 deletion packages/jest-worker/src/__tests__/Worker.test.js
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
2 changes: 1 addition & 1 deletion yarn.lock
Expand Up @@ -12944,7 +12944,7 @@ supports-color@^3.1.2, supports-color@^3.2.3:
dependencies:
has-flag "^1.0.0"

supports-color@^5.3.0, supports-color@^5.4.0:
supports-color@^5.3.0, supports-color@^5.4.0, supports-color@^5.5.0:
version "5.5.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f"
integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==
Expand Down