-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Possibility to write testEnvironment in esm #10018
Comments
Thanks for opening a separate issue! We can probably do something similar to what we do for importing config files, catching the error and check if it's My one concern is how this affects e.g. #8751. Probably not a huge issue - your transformer should just leave it alone. And I don't see a use case for both ESM and transpiling (people should just transpile to CJS in that case). |
Your proposal seems reasonable. I don't see use case of ESM and code transpiling either. |
@SimenB Thanks for all the work on Jest! Especially the transition to ESM! Do you think this feature could land in v27 ? |
This landed in #8751 and will be available in jest@27. You can test it via |
Wait, no you mean native ESM! 😅 That's not done but should be quite straightforward if anybody wants to open a PR. Need to take the approach of #9573. Should probably attempt to transpile it first, then check the if an error thrown is |
Ahah yeah I meant native ESM. Let me take a look at the code and see if I am able to help |
@SimenB checking in again to see how I can help move this forward |
@gilles-yvetot that's awesome someone has the same interest to introduce this feature. Unfortunately, I have no time to contribute, but I will appreciate, if I will be able to import and start my es6 server inside testEnvironment. 🤞 🤞 🤞 |
@kuka-radovan thanks! It is actually my first open-source PR and I am waiting for approval or advise on how to make it better |
Fixed in #11033 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🚀 Feature Proposal
It would be awesome if there will be possibility to create testEnvironment as esm. It is actually possible only as cjs.
Motivation
I need to test API of my server written as esm. I want to start it in testEnvironment so I will need to import it.
Pitch
From Jest v. 25.4.0 there is support of esm, so I believe, this feature is meaningful from this perspective.
The text was updated successfully, but these errors were encountered: