We had a dependabot pull which is upgrading jest, jest-cli and braces from the following versions:
Updates `braces` from 3.0.2 to 3.0.3
- [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md)
- [Commits](micromatch/[email protected])
Updates `jest` from 26.6.3 to 29.7.0
- [Release notes](https://github.com/jestjs/jest/releases)
- [Changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jestjs/jest/commits/v29.7.0/packages/jest)
Updates `jest-cli` from 26.6.3 to 29.7.0
- [Release notes](https://github.com/jestjs/jest/releases)
- [Changelog](https://github.com/jestjs/jest/blob/main/CHANGELOG.md)
- [Commits](https://github.com/jestjs/jest/commits/v29.7.0/packages/jest-cli)
We have a testSetup.jsx file which gets included from the jest.config.js file:
setupFilesAfterEnv: [
'@testing-library/jest-dom/extend-expect',
'<rootDir>/testSetup.jsx'
],
Unfortunately after the upgrade anything referencing global.window
is failing as it is saying that window is undefined. So for example the testSetup.jsx file fails on the following line:
TypeError: Cannot set properties of undefined (setting 'ApptentiveSDK')
117 | }
118 | */
> 119 | global.window.ApptentiveSDK = { createConversation: jest.fn(() => { }), engage: jest.fn(() => { }) }
| ^
120 |
121 | global.CSS = { supports: jest.fn() }
122 |
I’m not sure where to start digging for this one. If anyone can give me some direction it would be greatly appreciated.
So the issue appears to be that jsdom /a/72996199/1348329 is not the default starting with jest 28. I had to set the testEnvironment config to ‘jsdom’ and install npm install --save-dev jest-environment-jsdom