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

feature: allow ESM for test environment #11033

Merged
merged 15 commits into from
Apr 30, 2021
Merged

Conversation

gilles-yvetot
Copy link
Contributor

Summary

Support for native ESM has been included but we did not have the possibility yet to also use ESM for custom test environment

Test plan

I don't really know how to test that and I'd love some help on that

@gilles-yvetot
Copy link
Contributor Author

Anyone here?

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

Thanks, and sorry about the slow response!

In addition to the inline comment I made, this needs an integration test. You can look at e.g. #11163 where I added support for ESM transformers for inspiration for how to write the integration test

packages/jest-runner/src/runTest.ts Outdated Show resolved Hide resolved
Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

(oops, previous review should have been "request changed")

@gilles-yvetot
Copy link
Contributor Author

@SimenB I tried to add a dummy test. Simply create a simple ESM test environment and run a test with this environment.
I haven't worked on a repo that big so I'd probably need more guidance if that does not work :(

@gilles-yvetot
Copy link
Contributor Author

@SimenB I'd love to be able to test on my local repo and potentially start using it until #11167 is merged in.

Running npm rm jest && npm i git+ssh://[email protected]:gilles-yvetot/jest#feature/10018 install @jest/monorepo.
Do you have any tips on how to start using my branch?

Thanks a lot

@SimenB
Copy link
Member

SimenB commented Apr 14, 2021

@gilles-yvetot if you wanna test with a local build, we have instructions in CONTRIBUTING.md

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

Look pretty good! You also need to add a test which actually runs the integration test - something like https://github.com/facebook/jest/blob/master/e2e/__tests__/nativeEsm.test.ts (see https://github.com/facebook/jest/blob/master/CONTRIBUTING.md#integration-tests)

e2e/test-environment-esm/EnvESM.js Outdated Show resolved Hide resolved
e2e/test-environment-esm/EnvESM.js Outdated Show resolved Hide resolved
@SimenB SimenB changed the title feature: use ESM for test environment feature: allow ESM for test environment Apr 30, 2021
@SimenB SimenB merged commit 1a977d9 into jestjs:master Apr 30, 2021
@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 31, 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