Skip to content
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

Update to Jest 29 #5544

Merged
merged 9 commits into from
Mar 9, 2023
Merged

Update to Jest 29 #5544

merged 9 commits into from
Mar 9, 2023

Conversation

geriux
Copy link
Contributor

@geriux geriux commented Mar 9, 2023

This PR updates the Jest version to 29 to match Gutenberg's current version introduced in this PR.

To test CI checks should pass.

PR submission checklist:

  • I have considered adding unit tests where possible.
  • I have considered if this change warrants user-facing release notes more info and have added them to RELEASE-NOTES.txt if necessary.

@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented Mar 9, 2023

Wanna run full suite of Android and iOS UI tests? Click here and 'Approve' CI job!

@geriux geriux added Testing Anything related to automated tests dependencies Pull requests that update a dependency file labels Mar 9, 2023
@@ -34,7 +34,9 @@ module.exports = {
'<rootDir>/jetpack/',
'/__device-tests__/',
],
testURL: 'http://localhost/',
testEnvironmentOptions: {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testURL is deprecated so we needed to update it to the new format.

jest_setup.js Outdated Show resolved Hide resolved
jest_setup.js Outdated Show resolved Hide resolved
jest_setup.js Outdated
__esModule: true,
} ) );

jest.mock(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the Jest 29 update, there is an issue where it can't find the native export of this file so I added a mock.

@geriux geriux marked this pull request as ready for review March 9, 2023 11:45
@geriux geriux requested a review from fluiddot March 9, 2023 11:45
@geriux
Copy link
Contributor Author

geriux commented Mar 9, 2023

FYI there are a few CI failures for this PR due to other reasons like node failing to download.

"jest-image-snapshot": "^6.1.0",
"jest-jasmine2": "29.5.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jest-jasmine2 is no longer included with Jest and it has to be installed separately.

jest.config.js Outdated
@@ -25,7 +25,7 @@ module.exports = {
// Automatically clear mock calls and instances between every test
clearMocks: true,
preset: './gutenberg/node_modules/react-native/jest-preset.js',
setupFiles: [ '<rootDir>/' + configPath + '/setup.js' ],
setupFiles: [ '<rootDir>/' + configPath + '/setup.js', './jest_setup.js' ],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: I'm wondering if we could use a similar name format for jest_setup.js as this file, i.e. jest.setup.js, WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! I'll update it 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 9278461 and be3b94f

jest_setup.js Outdated Show resolved Hide resolved
jest_setup.js Outdated Show resolved Hide resolved
Copy link
Contributor

@fluiddot fluiddot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎊 ! Thanks @geriux for fixing this 🙇 !

I tested locally by running npm ci && npm run test and all tests passed ✅ .

@geriux geriux merged commit 1e5e634 into trunk Mar 9, 2023
@geriux geriux deleted the fix/jest-29 branch March 9, 2023 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file Testing Anything related to automated tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants