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

sharded / parallel tests and sort order #44

Closed
FDIM opened this issue Feb 13, 2018 · 2 comments
Closed

sharded / parallel tests and sort order #44

FDIM opened this issue Feb 13, 2018 · 2 comments

Comments

@FDIM
Copy link

FDIM commented Feb 13, 2018

First of all thanks for the reporter!

I think I've found a nice way to guarantee correct sort order even with shardTestFiles set to true. It was still a bit off with the one provided in the readme file.

What I do is patch jasmine2MetaDataBuilder and add instanceId to each spec which happens to be process.pid:

var org = { jasmine2MetaDataBuilder: htmlReporter.jasmine2MetaDataBuilder };
htmlReporter.jasmine2MetaDataBuilder = function () {
    var metadata = org.jasmine2MetaDataBuilder.apply(this, arguments);
    metadata.instanceId = process.pid;
    return metadata;
};

Sort function:

module.exports = function sort(a, b) {

    var valueA = a.instanceId * a.timestamp;
    var valueB = b.instanceId * b.timestamp;

    if (valueA < valueB) {
        return -1;
    }
    return 1;
}

It would be nice if something like this could be incorporated.

@Evilweed
Copy link
Owner

@FDIM Might be good idea to make this change in jasmine2MetaDataBuilder permanent (available for everyone without patching).

@Evilweed
Copy link
Owner

@FDIM I've found one issue (You were using sessionId name in one place and instanceId in other), fixed it, and updated base sort function to take into account instanceId.

Released as v1.2.0.
Thanks for PR!
Cheers! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants