Skip to content

Commit

Permalink
strip ansi codes from buggy version of supportsColor
Browse files Browse the repository at this point in the history
  • Loading branch information
spion committed Nov 22, 2018
1 parent 89257ef commit 726bf0f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 20 deletions.
10 changes: 5 additions & 5 deletions e2e/__tests__/coverage_report.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ test('collects coverage from duplicate files avoiding shared cache', () => {
});

test('generates coverage when using the testRegex config param ', () => {
const {stdout, status} = runJest(DIR, [
'--no-cache',
'--testRegex=__tests__',
'--coverage',
]);
const {stdout, status} = runJest(
DIR,
['--no-cache', '--testRegex=__tests__', '--coverage'],
//{stripAnsi: true},
);
expect(stdout).toMatchSnapshot();
expect(status).toBe(0);
});
7 changes: 4 additions & 3 deletions e2e/__tests__/typescript_coverage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
* @flow
*/

import path from 'path';
import {run} from '../Utils';
import runJest from '../runJest';
const path = require('path');
const {run} = require('../Utils');
const runJest = require('../runJest');
const stripAnsi = require('strip-ansi');

it('instruments and collects coverage for typescript files', () => {
const dir = path.resolve(__dirname, '../typescript-coverage');
Expand Down
1 change: 1 addition & 0 deletions packages/jest-worker/package.json
Original file line number Diff line number Diff line change
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
22 changes: 11 additions & 11 deletions packages/jest-worker/src/Worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import type {
WorkerOptions,
} from './types';

const supportsColor = require('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,23 +90,21 @@ export default class {
}

_initialize() {
const forceColor =
'FORCE_COLOR' in process.env
? process.env['FORCE_COLOR']
: // $FlowFixMe: Does not know about isTTY
process.stdout.isTTY
? '1'
: '0';
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, {
FORCE_COLOR: forceColor,
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
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
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

0 comments on commit 726bf0f

Please sign in to comment.