Skip to content

Commit

Permalink
fix: env is not passed to worker threads (nightwatchjs#3691)
Browse files Browse the repository at this point in the history
  • Loading branch information
vaibhavsingh97 committed Apr 20, 2023
1 parent 2bb54d3 commit ac3c506
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/runner/concurrency/worker-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class WorkerPool extends EventEmitter {
maxThreads: maxWorkerCount,
argv: args,
env: {
...process.env,
__NIGHTWATCH_PARALLEL_MODE: '1'
}
});
Expand Down
10 changes: 8 additions & 2 deletions test/src/runner/cli/testCliRunnerParallel.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ describe('Test CLI Runner in Parallel', function () {
});
}

before(function() {
beforeEach(function() {
mockery.enable({useCleanCache: true, warnOnReplace: false, warnOnUnregistered: false});
});

after(function() {
afterEach(function() {
mockery.deregisterAll();
mockery.resetCache();
mockery.disable();
Expand Down Expand Up @@ -66,6 +66,7 @@ describe('Test CLI Runner in Parallel', function () {
});

it('test run geckodriver with concurrency - worker threads', function () {
process.env.TEST_ENV = 'TEST';
class RunnerBaseMock extends RunnerBase {
static readTestSource(settings, argv) {
assert.strictEqual(settings.testWorkersEnabled, true);
Expand All @@ -80,6 +81,11 @@ describe('Test CLI Runner in Parallel', function () {
class WorkerProcessMock extends WorkerProcess {
addTask({colors}) {
assert.strictEqual(colors.length, 4);
assert.strictEqual(this.piscina.options.env.TEST_ENV, 'TEST');
assert(Object.keys(this.piscina.options.env).length > 1, 'process.env should have more than one key');

// cleaning the env
process.env.TEST_ENV = undefined;

return Promise.resolve(0);
}
Expand Down

0 comments on commit ac3c506

Please sign in to comment.