Consider disabling JSDOM by default
See original GitHub issueDo you want to request a feature or report a bug? Default change proposal (semver breaking)
What is the current behavior? Jest’s default testEnvironment is jsdom. I understand the intention of Jest is to follow convention over configuration and make things like DOM testing very easy for beginners with minimal configuration, but there is a large overhead to having jsdom enabled by default (often 3 times as slow to boot per test suite in my experience) and I don’t think most users even realize this is configuration.
What is the expected behavior? I think swapping the default to node would be nicer (of course, not without deprecation warnings, semver major breaking changes, and possibly a helpful error message when the DOM is accessed in the Node env). While I tend to disable jsdom because I never need it, I often forget and I’d rather have the default settings optimize for performance in this case. I think this would keep the testEnvironment settings more consistent with Jest’s other performance first defaults, like disabling coverage. It’s also worth mentioning that many usages of Jest even in web code don’t need jsdom, as shown in Jest’s own documentation on react-test-renderer.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:16
- Comments:29 (14 by maintainers)
Top GitHub Comments
^ landed, let’s swap default for 26
@cpojer @aaronabramov @thymikee thoughts on this?
It’s easier to google
document is not defined
than it is to discover your tests are a bit slower than they need to.We could also potentially special case errors like
document is not defined
,window is not defined
etc and provide a nice error message about setting environment.