Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
gravityvi committed Jul 25, 2023
1 parent 3a31fff commit 340801a
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/src/runner/cli/testCliRunnerParallel.js
Expand Up @@ -3,6 +3,7 @@ const path = require('path');
const mockery = require('mockery');
const common = require('../../../common.js');
const NightwatchClient = common.require('index.js');
const {settings} = common;

describe('Test CLI Runner in Parallel', function () {
const ChildProcess = common.require('runner/concurrency/child-process.js');
Expand Down Expand Up @@ -105,6 +106,51 @@ describe('Test CLI Runner in Parallel', function () {
});
});

it('run error test file with concurrency - worker threads', function() {
let numberOfTasks = 0;
class RunnerBaseMock extends RunnerBase {
static readTestSource(settings, argv) {
assert.strictEqual(settings.testWorkersEnabled, true);

return [
'test_file_1.js',
'test_file_2.js'
];
}
}

class WorkerProcessMock extends WorkerProcess {
addTask({colors}) {

this.__tasks.push(new Promise((resolve, reject) => {
setTimeout(()=>{
numberOfTasks++;
reject(new Error('Nigtwatch custom error'));
}, 10*(numberOfTasks+1));
}));

return Promise.resolve(0);
}
}
mockery.registerMock('./worker-process.js', WorkerProcessMock);
mockery.registerMock('../runner.js', RunnerBaseMock);

return NightwatchClient.runTests({
env: 'default',
config: path.join(__dirname, '../../../extra/withgeckodriver-concurrent.json')
}, settings({
globals: {
reporter() {
assert.strictEqual(numberOfTasks, 2);
}
},
use_child_process: false,
silent: false,
output: false,
output_folder: false
}));
});

it('start single test run with geckodriver and test workers enabled', function () {
const testPath = path.join(__dirname, '../../../sampletests/async/test/sample.js');
const runner = NightwatchClient.CliRunner({
Expand Down

0 comments on commit 340801a

Please sign in to comment.