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

assign process.env.JEST_WORKER_ID=1 when in runInBand mode #5860

Merged
merged 3 commits into from
Mar 23, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

### Fixes

* `[jest-runner]` Assign `process.env.JEST_WORKER_ID="1"` when in runInBand mode
([#5860](https://github.com/facebook/jest/pull/5860))
* `[jest-cli]` Add descriptive error message when trying to use
`globalSetup`/`globalTeardown` file that doesn't export a function.
([#5835](https://github.com/facebook/jest/pull/5835))
Expand Down
19 changes: 19 additions & 0 deletions packages/jest-runner/src/__tests__/test_runner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,22 @@ test('does not inject the rawModuleMap in serial mode', () => {
]);
});
});

test('assign process.env.JEST_WORKER_ID = 1 when in runInBand mode', () => {
const globalConfig = {maxWorkers: 1, watch: false};
const config = {rootDir: '/path/'};
const context = {config};

return new TestRunner(globalConfig)
.runTests(
[{context, path: './file.test.js'}],
new TestWatcher({isWatchMode: globalConfig.watch}),
() => {},
() => {},
() => {},
{serial: true},
)
.then(() => {
expect(process.env.JEST_WORKER_ID).toBe('1');
});
});
1 change: 1 addition & 0 deletions packages/jest-runner/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class TestRunner {
onResult: OnTestSuccess,
onFailure: OnTestFailure,
) {
process.env.JEST_WORKER_ID = '1';
const mutex = throat(1);
return tests.reduce(
(promise, test) =>
Expand Down