-
Notifications
You must be signed in to change notification settings - Fork 840
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
[Chore] upgrade Jest to v29 #7821
Conversation
c898270
to
74f17da
Compare
8868bb3
to
d2d12cc
Compare
fix config related issues
- updates are related to newly supported css, underlying color conversion changes and syntax changes of the snapshot generation
updates EuiPopover handleStrandedFocus condition as on mount with isOpen the stranded focus is on the panel
- updates all instances of openPopover and closePopover to RTL to not mix testing approaches between them
d2d12cc
to
9ee49dd
Compare
I'm in the process of reviewing this PR! |
); | ||
|
||
mockCell.append(mockPopoverAnchor); | ||
// NOTE: [issue for React 16/17] we need to append the cell to the body instead of the container |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this only related to jest v29?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It did show up in the migration but I can't fully answer this, as I did not convert this to RTL with jest v24 but did the migration to jest v29 and conversion to RTL at the same time 😅
It might be a difference in how/when RTL and Enzyme render/mount things to the DOM also? 🤷♀️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look and work great! Thank you for putting effort into converting more tests to RTL 😄
Preview staging links for this PR:
|
💚 Build Succeeded
History
|
Summary
closes #6813
closes #7322
Note
This PR upgrades
jest
and all related dependencies (includingjsdom
) to their latest versions. With that EUI will be usingjest
version^29.7.0
andjsdom
version24.1.0
now.Changes
Note
The upgrade resulted in 226 failed unit tests and 84 failed snapshot tests
Dependencies
1. 📦 Updated main jest testing dependencies
jest
-^29.7.0
jest-cli
-^29.7.0
@types/jest
-^29.5.12
babel-jest
:^29.7.0
eslint-plugin-jest
:^28.5.0
🔗 See the change here
2. 📦 added
jest-environment-jsdom
dependencySince version 28
jest
does not include the environment by default anymore. We're adding it manually now.jest-environment-jsdom
-^29.7.0
🔗 See the change here
It's enabled in the jest config (
packages/eui/scripts/jest/config.js
) viatestEnvironment
option:testEnvironment: 'jsdom'
🔗 See the change here
Setup
1. 🧪 update
getCacheDirectory
importWe can't import from the file directly anymore from the
jest-config
package subdirectory as it's not covered by theexports
option defined in itspackage.json
file. We can import the config and use the definedcacheDirectory
default option instead (jest-config).🔗 See the change here
2. 🧪 add
modulenameMapper
option foruuid
as it causes syntax erros due to using es6 syntax🔗 See the change here
3. 📦 fix
jsdom
version to a newer version than used byjest-environment-jsdom
With the update there were tests failing on color value changes and some of these showed that
hsl()
inputs are a) no longer output as is and b) not output correctly. (hsl values would show up asrgb(0, 0, 0)
ℹ️ It's expected that
jsdom
converts color values torgb
values and it usescssstyle
for that. There was a fix for the wrongly convertedhsl
values from version4.0.0
(changelog) which is available fromjsdom
version23.1.0
(changelog).The latest
jest-environment-jsdom
version29.7.0
however still usesjsdom
version20.0.0
and the most recent alpha version30.0.0-alpha.1
only uses22.0.0
(changelog)💡 Instead we can use
resolutions
to enforcejsdom
version24.0.0
for now which includes thehsl
conversion fix and did not seem to affect any other tests.🔗 See change here
Important
After this upgrade all color values are output as converted
rgb
for testing (unit and snapshot) which means we need to assert color checks usingrgb
values.Broken tests
1. 🎨 Updates to test and snapshots as general side effects due to changes in the versions
There were a few generic reasons tests needed updating, which are:
aspect-ratio
,cal()
, css properties) (changes 1, 2, 3)Object {}
vs{}
orArray []
vs[]
)2. 💥 Further updates due to broken test functionality
There were some tests that broke in functionality and the main point of friction was handling focus in enzyme tests.
As we're migrating to RTL (testing-library/react) this was a good opportunity to update failing tests to use RTL which generally also fixed the issues.
Note
This PR only updates the min. required parts of tests to RTL to ensure tests are passing
This is to keep within the scope of the tasks. For some larger tests (I'm looking at you, EuiDataGrid) this still means that many updates to the code were done as there where many usages of updated functionality.
QA