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

Make Jest's Test Runner configurable. #4240

Merged
merged 1 commit into from
Aug 10, 2017
Merged

Make Jest's Test Runner configurable. #4240

merged 1 commit into from
Aug 10, 2017

Conversation

cpojer
Copy link
Member

@cpojer cpojer commented Aug 10, 2017

Summary

This change adds a runner option to ProjectConfig that points to jest-runner but can be customized per project to any test runner. To ensure performance doesn't suffer with this new feature when using the MPR, multiple contexts that point to the same runner are merged and tests are run in the same runner instance, rather than creating a new instance per context. This means that there should be no performance penalty for existing MPR projects.

This is conflicting somewhat with the testRunner option that allows to pick jest-jasmine2 or jest-circus, however in this new world ProjectConfigs will be entirely jest-runner specific and variadic, and out of Jest's immediate control, so I don't think this matters long term and there are pending changes to be made to configs to support that. I think it makes more sense to consider this option the runner, add an option library (for lack of a better name) which replaces testRunner. I think we can make this decision later and I expect there to be more runners than testRunners going forward, so we may even want to kill the setting entirely and make the runner as compose-able as possible.

Test plan

jest + manual verification that it only creates one runner for the MPR right now.

contexts.forEach(({config}) => {
if (!testRunners[config.runner]) {
// $FlowFixMe
testRunners[config.runner] = new (require(config.runner))(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe not at this point, but eventually it would be nice to guard that expression and throw a human readable error.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, maybe we can cast a TestRunner type here?

}
});

const testRuns = this._partitionTests(testRunners, tests);
Copy link
Collaborator

Choose a reason for hiding this comment

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

testsByRunner seems more appropriate to me.

Copy link
Collaborator

@thymikee thymikee left a comment

Choose a reason for hiding this comment

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

looks good

@thymikee
Copy link
Collaborator

You need to update the config snapshot

@cpojer cpojer force-pushed the master branch 3 times, most recently from a4cddb0 to 2ddb379 Compare August 10, 2017 21:00
@cpojer cpojer merged commit de8f2e3 into jestjs:master Aug 10, 2017
@cpojer cpojer changed the title Make Jest’s Test Runner configurable. Make Jest's Test Runner configurable. Aug 11, 2017
tushardhole pushed a commit to tushardhole/jest that referenced this pull request Aug 21, 2017
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants