Member-only story
Jest 27 Has New Default
2 min readJun 5, 2021
Jest is a JavaScript testing framework maintained by Facebook
Default test environment from “jsdom” to “node”.
Modern fake timers implementation will now be the default.
The big news here is that Jest is changing the default test environment from “jsdom” to “node”.
- The most developers will see a big performance boost because they’ll no longer be unknowingly using an expensive DOM environment that they (usually) don’t need.
- Running tests in a JSDOM environment incurs a significant performance overhead. Because this was the default behavior of Jest unless otherwise configured up until now, users who are writing Node apps, for example, may not even know they are given an expensive DOM environment that they do not even need.
- For this reason, they changed the default test environment from “jsdom” to “node”. If you are affected by this change because you use DOM APIs and do not have the test environment explicitly configured, you should be receiving an error when e.g. document is accessed, and you can configure “testEnvironment”: “jsdom” or use per-file environment configuration to resolve this.