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

fix(jest-runner): Support Jest v27 #2861

Merged
merged 13 commits into from May 28, 2021
Merged

fix(jest-runner): Support Jest v27 #2861

merged 13 commits into from May 28, 2021

Conversation

Garethp
Copy link
Contributor

@Garethp Garethp commented Apr 29, 2021

In Jest version 27 they're changing the default test runner to jest-circus instead of jasmine, which means that the global.jasmine variables never get set up. Since we've already implemented perTest coverage for jest-circus, all we need to do is not try to attach a reporter to the globa.jasmine if it doesn't exist.

I don't see any tests for this bit of code already, and I'm not keen on creating a new e2e test for an alpha release of jest. That being said, optional chaining here doesn't change the behavior, so I think this should be a safe fix. What do you think @nicojs

Fixes #2923

@Garethp Garethp requested a review from nicojs April 29, 2021 16:19
Copy link
Member

@nicojs nicojs left a comment

Choose a reason for hiding this comment

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

Thanks @Garethp

Did you still want to do the e2e testing in this branch as well?

We currently have an explicit list of defaults defined here:

/**
* Jest's defaults.
* @see https://jestjs.io/docs/en/configuration
*/
const jestDefaults = Object.freeze({
testRunner: 'jest-jasmine2',
testEnvironment: 'jsdom',
});

Would there be a way to extract the defaults from jest? I can see it is exported from jest here:

https://github.com/facebook/jest/blob/510c8bb40d42095e8a3c78898579b9624e33e432/packages/jest-config/src/index.ts#L22

If we want to get at it, we should try to resolve it from jest. Kind of tricky, but could be done.

The benefit would be that we can choose to not include jasmine explicitly. The idea is that it would still crash if something else is wrong with jasmine, since coverage analysis perTest would be broken.

@nicojs nicojs changed the title fix(jest-runner): Don't try to add a reporter to the jasmine env if the jasmine env doesn't exist fix(jest-runner): Support Jest v27 May 28, 2021
@nicojs nicojs enabled auto-merge (squash) May 28, 2021 06:57
@nicojs nicojs merged commit 8d3560b into master May 28, 2021
@nicojs nicojs deleted the fix(jest-runner)_jest-v27 branch May 28, 2021 07:12
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

Successfully merging this pull request may close these issues.

Jest 27 - unable to run stryker
2 participants