Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 168aa65

Browse files
committedDec 12, 2017
Remove debug and inspect flags from the arguments sent to the child
1 parent c3db693 commit 168aa65

File tree

5 files changed

+36
-21
lines changed

5 files changed

+36
-21
lines changed
 

‎CHANGELOG.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22

33
### Fixes
44

5+
* `[jest-worker]` Remove `debug` and `inspect` flags from the arguments sent to
6+
the child
57
* `[jest-config]` Use all `--testPathPattern` and `<regexForTestFiles>` args in
68
`testPathPattern`([#5066](https://github.com/facebook/jest/pull/5066))
7-
* `[jest-cli]` Do not support `--watch` inside non-version-controlled environments
8-
([#5060](https://github.com/facebook/jest/pull/5060))
9+
* `[jest-cli]` Do not support `--watch` inside non-version-controlled
10+
environments ([#5060](https://github.com/facebook/jest/pull/5060))
911
* `[jest-config]` Escape Windows path separator in testPathPattern CLI arguments
1012
([#5054](https://github.com/facebook/jest/pull/5054)
11-
* `[jest-jasmine]` Register sourcemaps as node environment to improve performance with jsdom ([#5045](https://github.com/facebook/jest/pull/5045))
13+
* `[jest-jasmine]` Register sourcemaps as node environment to improve
14+
performance with jsdom ([#5045](https://github.com/facebook/jest/pull/5045))
1215
* `[pretty-format]` Do not call toJSON recursively
1316
([#5044](https://github.com/facebook/jest/pull/5044))
1417
* `[pretty-format]` Fix errors when identity-obj-proxy mocks CSS Modules
@@ -66,8 +69,8 @@
6669

6770
### Features
6871

69-
* `[jest-config]` Add `testEnvironmentOptions` to apply to jsdom options or node context.
70-
([#5003](https://github.com/facebook/jest/pull/5003))
72+
* `[jest-config]` Add `testEnvironmentOptions` to apply to jsdom options or node
73+
context. ([#5003](https://github.com/facebook/jest/pull/5003))
7174
* `[jest-jasmine2]` Update Timeout error message to `jest.timeout` and display
7275
current timeout value ([#4990](https://github.com/facebook/jest/pull/4990))
7376
* `[jest-runner]` Enable experimental detection of leaked contexts

‎docs/GlobalAPI.md

+13-12
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ environment. You don't have to require or import anything to use them.
1919
Runs a function after all the tests in this file have completed. If the function
2020
returns a promise, Jest waits for that promise to resolve before continuing.
2121

22-
Optionally, you can provide a `timeout` (in milliseconds) for specifying how long to wait
23-
before aborting. _Note: The default timeout is 5 seconds._
22+
Optionally, you can provide a `timeout` (in milliseconds) for specifying how
23+
long to wait before aborting. _Note: The default timeout is 5 seconds._
2424

2525
This is often useful if you want to clean up some global setup state that is
2626
shared across tests.
@@ -66,8 +66,8 @@ Runs a function after each one of the tests in this file completes. If the
6666
function returns a promise, Jest waits for that promise to resolve before
6767
continuing.
6868

69-
Optionally, you can provide a `timeout` (in milliseconds) for specifying how long to wait
70-
before aborting. _Note: The default timeout is 5 seconds._
69+
Optionally, you can provide a `timeout` (in milliseconds) for specifying how
70+
long to wait before aborting. _Note: The default timeout is 5 seconds._
7171

7272
This is often useful if you want to clean up some temporary state that is
7373
created by each test.
@@ -112,8 +112,8 @@ If you want to run some cleanup just once, after all of the tests run, use
112112
Runs a function before any of the tests in this file run. If the function
113113
returns a promise, Jest waits for that promise to resolve before running tests.
114114

115-
Optionally, you can provide a `timeout` (in milliseconds) for specifying how long to wait
116-
before aborting. _Note: The default timeout is 5 seconds._
115+
Optionally, you can provide a `timeout` (in milliseconds) for specifying how
116+
long to wait before aborting. _Note: The default timeout is 5 seconds._
117117

118118
This is often useful if you want to set up some global state that will be used
119119
by many tests.
@@ -157,8 +157,8 @@ Runs a function before each of the tests in this file runs. If the function
157157
returns a promise, Jest waits for that promise to resolve before running the
158158
test.
159159

160-
Optionally, you can provide a `timeout` (in milliseconds) for specifying how long to wait
161-
before aborting. _Note: The default timeout is 5 seconds._
160+
Optionally, you can provide a `timeout` (in milliseconds) for specifying how
161+
long to wait before aborting. _Note: The default timeout is 5 seconds._
162162

163163
This is often useful if you want to reset some global state that will be used by
164164
many tests.
@@ -327,8 +327,9 @@ test('did not rain', () => {
327327
```
328328

329329
The first argument is the test name; the second argument is a function that
330-
contains the expectations to test. The third argument (optional) is `timeout` (in milliseconds)
331-
for specifying how long to wait before aborting. _Note: The default timeout is 5 seconds._
330+
contains the expectations to test. The third argument (optional) is `timeout`
331+
(in milliseconds) for specifying how long to wait before aborting. _Note: The
332+
default timeout is 5 seconds._
332333

333334
> Note: If a **promise is returned** from `test`, Jest will wait for the promise
334335
> to resolve before letting the test complete. Jest will also wait if you
@@ -358,8 +359,8 @@ When you are debugging a large codebase, you will often only want to run a
358359
subset of tests. You can use `.only` to specify which tests are the only ones
359360
you want to run.
360361

361-
Optionally, you can provide a `timeout` (in milliseconds) for specifying how long to wait
362-
before aborting. _Note: The default timeout is 5 seconds._
362+
Optionally, you can provide a `timeout` (in milliseconds) for specifying how
363+
long to wait before aborting. _Note: The default timeout is 5 seconds._
363364

364365
For example, let's say you had these tests:
365366

‎packages/jest-worker/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ to `3`, pass `Infinity` to allow endless retries.
8787
#### `forkOptions: Object` (optional)
8888

8989
Allow customizing all options passed to `childProcess.fork`. By default, some
90-
values are set (`cwd` and `env`), but you can override them and customize the
91-
rest. For a list of valid values, check
90+
values are set (`cwd`, `env` and `execArgv`), but you can override them and
91+
customize the rest. For a list of valid values, check
9292
[the Node documentation](https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options).
9393

9494
#### `computeWorkerKey: (method: string, ...args: Array<any>) => ?string` (optional)

‎packages/jest-worker/src/__tests__/worker.test.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ import {
2121
let Worker;
2222
let forkInterface;
2323
let childProcess;
24+
let properProcess;
2425

2526
beforeEach(() => {
2627
jest.mock('child_process');
28+
properProcess = process;
2729

2830
childProcess = require('child_process');
2931
childProcess.fork.mockImplementation(() => {
@@ -41,14 +43,19 @@ beforeEach(() => {
4143

4244
afterEach(() => {
4345
jest.resetModules();
46+
// eslint-disable-next-line no-native-reassign
47+
process = properProcess;
4448
});
4549

4650
it('passes fork options down to child_process.fork, adding the defaults', () => {
4751
const child = require.resolve('../child');
52+
53+
Object.assign(process, {execArgv: ['--inspect', '-p']});
54+
4855
new Worker({
4956
forkOptions: {
5057
cwd: '/tmp',
51-
execArgv: ['--no-warnings'],
58+
execPath: 'hello',
5259
},
5360
maxRetries: 3,
5461
workerPath: '/tmp/foo/bar/baz.js',
@@ -58,7 +65,8 @@ it('passes fork options down to child_process.fork, adding the defaults', () =>
5865
expect(childProcess.fork.mock.calls[0][1]).toEqual({
5966
cwd: '/tmp', // Overridden default option.
6067
env: process.env, // Default option.
61-
execArgv: ['--no-warnings'], // Added option.
68+
execArgv: ['-p'], // Filtered option.
69+
execPath: 'hello', // Added option.
6270
silent: true, // Default option.
6371
});
6472
});

‎packages/jest-worker/src/worker.js

+3
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ export default class {
8080
{
8181
cwd: process.cwd(),
8282
env: process.env,
83+
// suppress --debug / --inspect flags while preserving others (like --harmony)
84+
// inspired by https://github.com/rvagg/node-worker-farm/blob/f63d988c307a6805e03b1650f8ef0fb7ca6f1546/lib/fork.js
85+
execArgv: process.execArgv.filter(v => !/^--(debug|inspect)/.test(v)),
8386
silent: true,
8487
},
8588
this._options.forkOptions,

0 commit comments

Comments
 (0)
Please sign in to comment.