-
-
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
feat(jest-environment-{node,jsdom}): allow specifying customExportConditions
#12774
Conversation
Mention here? https://jestjs.io/docs/configuration#testenvironmentoptions-object Only suggestion |
CHANGELOG.md
Outdated
@@ -2,6 +2,8 @@ | |||
|
|||
### Features | |||
|
|||
- `[jest-environment-jsdom]` Allow specifying `customExportConditions` instead of the default `'browser'` ([#12774](https://github.com/facebook/jest/pull/12774)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add support to node env as well?
Yeah that's the only place where it could make sense to mention, especially if we add support for node too. Slightly awkward though since they're environment-specific and thus all just "example" mentions |
6ba206f
to
0783267
Compare
customExportConditions
instead of the default 'browser'
customExportConditions
0783267
to
8480107
Compare
@SimenB added a lil mention to docs, and made node env also support it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff
Oh, maybe tweak "override" wording https://jestjs.io/docs/upgrading-to-jest28#packagejson-exports |
8480107
to
d7a6ba6
Compare
@SimenB It would be nice if the initial value of Rationale: In the jsdom runtime context, most of the time you want a package's "browser" conditional export, but other times it is better to use the "node" conditional export, since jsdom is missing certain browser features like It would be nice if cross-env package authors were able to add a conditional "jsdom" export to package.json to direct to the correct implementation when running the code in a jsdom runtime context, f.ex. when running Jest. We actually already added "jsdom" conditional exports in addition to "node" and "browser" for our internal packages to make them work with Jest unit tests, and for now we set jest.config's But I believe this could have been the initial value for |
I don't think we'll add any defaults beyond ones specified here: https://nodejs.org/api/packages.html#community-conditions-definitions |
@SimenB I can live with that, I can anyway configure it manually in jest.config.js. But personally I still think it would be correct to express this environment condition, since the runtime environment in my opinion is not correctly identified by "browser" or "node". FYI: Webpack is utilizing non-standard custom conditions quite extensively to enable advanced features: |
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. |
Allow
customExportConditions
in both of our environments.Tested using e2e.
Documented in an awkward but the only place.