-
Notifications
You must be signed in to change notification settings - Fork 58
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
Update to Jest 29 #5544
Changes from 4 commits
d62b91c
7f3336d
bf8f545
507f9a3
f6f969a
9278461
be3b94f
7e7d3b3
2952181
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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' ], | ||
setupFilesAfterEnv: [ '<rootDir>/' + configPath + '/setup-after-env.js' ], | ||
testMatch: [ '<rootDir>/src/**/test/*.[jt]s?(x)' ], | ||
testPathIgnorePatterns: [ | ||
|
@@ -34,7 +34,9 @@ module.exports = { | |
'<rootDir>/jetpack/', | ||
'/__device-tests__/', | ||
], | ||
testURL: 'http://localhost/', | ||
testEnvironmentOptions: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
url: 'http://localhost/', | ||
}, | ||
// Add the `Libraries/Utilities` subfolder to the module directories, otherwise haste/jest doesn't find Platform.js on Travis, | ||
// and add it first so https://github.com/facebook/react-native/blob/v0.60.0/Libraries/react-native/react-native-implementation.js#L324-L326 doesn't pick up the Platform npm module. | ||
moduleDirectories: [ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Jetpack mocks | ||
global.window.JP_CONNECTION_INITIAL_STATE = {}; | ||
fluiddot marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
jest.mock( './jetpack/projects/js-packages/config/src', () => ( { | ||
fluiddot marked this conversation as resolved.
Show resolved
Hide resolved
|
||
__esModule: true, | ||
} ) ); | ||
|
||
jest.mock( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
'./jetpack/projects/js-packages/shared-extension-utils/index.js', | ||
() => ( { | ||
__esModule: true, | ||
...jest.requireActual( | ||
'./jetpack/projects/js-packages/shared-extension-utils/index.js' | ||
), | ||
getHostAppNamespace: jest.fn(), | ||
} ) | ||
); |
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.
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?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.
Sure! I'll update it 👍
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.
Updated in 9278461 and be3b94f