Closed klappradla closed 2 years ago
Out of curiosity: Did you notice a difference in the time it takes to run the tests?
Haha, I was curious as well 🧐 - tried out two different setups:
Run in the node
environment and only switch to jsdom
where necessary (so essentially how it's set up in this PR)
Run everything in json
Configured like this globally in the jest.config.js
file: testEnvironment: 'jsdom'
Results: pretty much no difference 😉
Multi environment:
$ time yarn test
…
Time: 5.691 s, estimated 6 s
Ran all test suites.
✨ Done in 6.64s.
yarn test 27.86s user 6.21s system 493% cpu 6.909 total
jsdom
environment
$ time yarn test
…
Time: 6.226 s
Ran all test suites.
✨ Done in 7.14s.
yarn test 31.29s user 6.93s system 515% cpu 7.413 total
🤷
This updates Jest (and babel-jest) to patch a security vulnerability on a package the old versions depended on:
set-value
.See: https://github.com/advisories/GHSA-4jqc-8m5r-9rpr
With the update, we're now on Jest v27. On that version, Jest uses the
node
environment as the default environment for running tests in, instead of the slowerjsdom
environment. This means, tests which use the DOM API need to be switched back to run in thejsdom
environment.See https://jestjs.io/blog/2021/05/25/jest-27#flipping-defaults for details about the change.
For projects where only some tests require the DOM API, the Jest team recommends to still run the whole suite in the
node
environment (faster) and recommend thejsdom
environment only for those tests where it's actually needed.