-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Decide on Jest's default environment #338
Comments
See the discussion in #355. We will provide documentation on how to use jsdom with CRA. |
I'm going to try what both options feel like today and make the call. Ideally I would like to ship performant default and provide clear instructions automatically when somebody tries to use things relying on jsdom. I'm not sure if it's even possible through. |
I'm happy to do whatever you decide is best for CRA. I never tried to load jsdom from within Jest using the node environment but it is definitely a use-case we should support. I have time tomorrow to make anything happen. |
Decided to go with jsdom by default but as a flag so people who know what it is can disable it. |
Jest ships with
jsdom
by default. With the test renderer we don't need jsdom so I recommend people to use thenode
environment, also in CRA: https://github.com/facebookincubator/create-react-app/blob/master/scripts/utils/create-jest-config.js#L22However, I expect people would like to continue using enzyme until they are fully bought into snapshot testing and until the test renderer supports all the APIs to put enzyme itself (or a compatible API) on top of the test renderer.
Here are the possible solutions:
testEnvironment
config I linked to above. The only downside is that Jest's startup increases by 500ms because jsdom takes 500ms to require. (simply measurerequire('jsdom');
) . This is the easiest fix.const window = require('jsdom').jsdom(...).defaultView;
I don't have strong feelings either way. Personally I'd like to get into a place where jsdom is available but not the default in Jest (maybe with a
@jest-env jsdom
directive in the header; we haven't finalized our ideas yet).For CRA, given that people predominantly write web apps, it likely makes sense to take this performance hit and go with option one. It's a bit slower but the saner no-config default.
The text was updated successfully, but these errors were encountered: