Skip to content

fix --suites flag for run workers #2655

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

Merged
merged 1 commit into from
Nov 8, 2020
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
4 changes: 3 additions & 1 deletion lib/workers.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,12 @@ class Workers extends EventEmitter {
* @param {Number} numberOfWorkers
*/
createGroupsOfSuites(numberOfWorkers) {
const files = this.codecept.testFiles;
const groups = populateGroups(numberOfWorkers);

const mocha = Container.mocha();

mocha.files = files;
mocha.loadFiles();
Copy link
Contributor

@DavertMik DavertMik Nov 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, this make sense to me. As it is the same behavior that in createGroupOfTests
Thanks @Georgegriff

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I checked the 2.x code the suite flag used to have this exact logic looks like was just missed in refactor

mocha.suite.suites.forEach((suite) => {
const i = indexOfSmallestElement(groups);
suite.tests.forEach((test) => {
Expand Down
14 changes: 14 additions & 0 deletions test/runner/run_workers_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@ describe('CodeceptJS Workers Runner', function () {
});
});

it('should use suites', function (done) {
if (!semver.satisfies(process.version, '>=11.7.0')) this.skip('not for node version');
exec(`${codecept_run} 2 --suites`, (err, stdout) => {
expect(stdout).toContain('CodeceptJS'); // feature
expect(stdout).toContain('Running tests in 2 workers'); // feature
expect(stdout).toContain('glob current dir');
expect(stdout).toContain('From worker @1_grep print message 1');
expect(stdout).toContain('From worker @2_grep print message 2');
expect(stdout).not.toContain('this is running inside worker');
expect(err.code).toEqual(1);
done();
});
});

it('should show failures when suite is failing', function (done) {
if (!semver.satisfies(process.version, '>=11.7.0')) this.skip('not for node version');
exec(`${codecept_run} 2 --grep "Workers Failing"`, (err, stdout) => {
Expand Down