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

Use default export of jest-environment if present #331

Merged
merged 1 commit into from
Mar 7, 2022

Conversation

noseworthy
Copy link
Contributor

@noseworthy noseworthy commented Mar 7, 2022

Jest v28 is going to start using ESM, and the latest release candidate
has started exporting modules with ESM syntax:

jestjs/jest#12340

This breaks jest-mongodb when importing jest-environment-node. In order
to properly import this module when running in jest v28 we need to look
for the default export.

If the default export is present, use that, otherwise use the test
environment as normal.

Jest v28 is going to start using ESM, and the latest release candidate
has started exporting modules with ESM syntax:

jestjs/jest#12340

This breaks jest-mongodb when importing jest-environment-node. In order
to properly import this module when running in jest v28 we need to look
for the default export.

If the default export is present, use that, otherwise use the test
environment as normal.
@noseworthy
Copy link
Contributor Author

Hey @vladgolubev, thanks for your work on this package! It's been super useful to us. We're upgrading to the v28 release candidate of jest in order to take advantage of the new test sharding feature: jestjs/jest#12546

We've got everything else working, but this package is preventing us from upgrading because of how it imports the test environment. I've got a little patch here that works for us and I hope would be backwards compatible for your purposes. I'd really appreciate it if you could take a look when you get a chance.

Thanks!

@vladholubiev vladholubiev merged commit 2379a0d into shelfio:master Mar 7, 2022
@noseworthy noseworthy deleted the prep-for-jest-28 branch March 7, 2022 17:08
@vladholubiev
Copy link
Member

@noseworthy see https://github.com/shelfio/jest-mongodb/releases/tag/v2.2.1

Thanks for your contribution!

@noseworthy
Copy link
Contributor Author

Woah, that was super fast. Thanks so much!

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

Successfully merging this pull request may close these issues.

2 participants