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
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gutenberg
Submodule gutenberg updated 86 files
+425 −4 changelog.txt
+14 −27 docs/contributors/code/e2e/README.md
+6 −0 docs/manifest.json
+1 −1 docs/reference-guides/core-blocks.md
+57 −0 docs/reference-guides/theme-json-reference/styles-versions.md
+20 −0 docs/reference-guides/theme-json-reference/theme-json-living.md
+3 −0 docs/toc.json
+1 −1 gutenberg.php
+4 −0 lib/block-supports/layout.php
+1 −1 lib/class-wp-theme-json-gutenberg.php
+0 −28 lib/compat/wordpress-6.1/block-template-utils.php
+143 −0 lib/compat/wordpress-6.2/block-template-utils.php
+2,730 −5,989 package-lock.json
+7 −7 package.json
+1 −1 packages/README.md
+2 −1 packages/block-editor/src/components/block-settings-menu-controls/index.js
+48 −38 packages/block-editor/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js
+1 −1 packages/block-editor/src/components/global-styles/test/use-global-styles-output.js
+1 −1 packages/block-editor/src/components/global-styles/use-global-styles-output.js
+7 −4 packages/block-editor/src/hooks/layout.js
+23 −17 packages/block-editor/src/layouts/constrained.js
+1 −1 packages/block-library/src/buttons/edit.native.js
+6 −1 packages/block-library/src/cover/block.json
+2 −0 packages/block-library/src/cover/index.js
+20 −0 packages/block-library/src/cover/variations.js
+16 −12 packages/block-library/src/embed/edit.js
+28 −18 packages/block-library/src/embed/edit.native.js
+12 −0 packages/block-library/src/embed/test/index.js
+29 −8 packages/block-library/src/embed/util.js
+11 −18 packages/block-library/src/navigation/edit/index.js
+0 −4 packages/block-library/src/navigation/edit/menu-inspector-controls.js
+1 −0 packages/block-library/src/post-featured-image/style.scss
+1 −0 packages/components/CHANGELOG.md
+1 −1 packages/components/src/mobile/bottom-sheet/bottom-sheet-navigation/test/navigation-container.native.js
+1 −1 packages/components/src/mobile/link-settings/test/link-settings-navigation.native.js
+2 −1 packages/components/src/resizable-box/resize-tooltip/styles/resize-tooltip.styles.ts
+1 −1 packages/core-data/README.md
+1 −1 packages/data/src/test/privateAPIs.js
+1 −8 packages/data/src/test/registry.js
+4 −0 packages/e2e-test-utils/CHANGELOG.md
+1 −1 packages/e2e-test-utils/package.json
+4 −0 packages/e2e-tests/CHANGELOG.md
+7 −0 packages/e2e-tests/babel.config.js
+3 −3 packages/e2e-tests/package.json
+1 −1 packages/e2e-tests/specs/editor/various/__snapshots__/inserting-blocks.test.js.snap
+4 −2 packages/e2e-tests/specs/site-editor/settings-sidebar.test.js
+5 −0 packages/edit-post/src/components/header/header-toolbar/index.native.js
+6 −8 packages/edit-post/src/components/layout/index.js
+1 −1 packages/edit-post/src/components/sidebar/post-template/create-modal.js
+1 −1 packages/edit-post/src/test/editor.native.js
+1 −1 packages/edit-site/src/components/add-new-template/new-template.js
+3 −2 packages/edit-site/src/components/layout/index.js
+1 −0 packages/edit-site/src/components/list/table.js
+3 −40 packages/edit-site/src/components/sidebar-navigation-screen-navigation-menus/index.js
+4 −0 packages/edit-site/src/components/sidebar-navigation-screen-navigation-menus/style.scss
+1 −1 packages/edit-site/src/components/site-hub/style.scss
+10 −17 packages/edit-site/src/components/template-part-converter/convert-to-regular.js
+9 −16 packages/edit-site/src/components/template-part-converter/convert-to-template-part.js
+28 −12 packages/edit-site/src/components/template-part-converter/index.js
+2 −4 packages/editor/src/components/autosave-monitor/test/index.js
+1 −1 packages/format-library/src/link/test/index.native.js
+4 −0 packages/jest-console/CHANGELOG.md
+2 −2 packages/jest-console/package.json
+4 −0 packages/jest-preset-default/CHANGELOG.md
+3 −4 packages/jest-preset-default/README.md
+0 −1 packages/jest-preset-default/jest-preset.js
+2 −2 packages/jest-preset-default/package.json
+4 −0 packages/jest-puppeteer-axe/CHANGELOG.md
+1 −1 packages/jest-puppeteer-axe/package.json
+14 −0 packages/react-native-editor/__device-tests__/helpers/utils.js
+62 −1 packages/react-native-editor/__device-tests__/pages/editor-page.js
+0 −1 packages/react-native-editor/jest_ui.config.js
+1 −1 packages/react-native-editor/jest_ui_test_environment.js
+1 −1 packages/report-flaky-tests/package.json
+4 −0 packages/scripts/CHANGELOG.md
+2 −6 packages/scripts/config/jest-environment-puppeteer/index.js
+4 −3 packages/scripts/package.json
+1 −1 packages/url/src/test/fixtures/wpt-data.json
+3 −3 phpunit/block-supports/layout-test.php
+1 −1 phpunit/class-wp-theme-json-test.php
+42 −1 schemas/json/theme.json
+2 −0 test/native/babel.config.js
+1 −1 test/native/integration-test-helpers/with-fake-timers.js
+17 −15 test/native/jest.config.js
+4 −1 test/unit/jest.config.js
+35 −0 test/unit/scripts/resolver.js
6 changes: 4 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

setupFilesAfterEnv: [ '<rootDir>/' + configPath + '/setup-after-env.js' ],
testMatch: [ '<rootDir>/src/**/test/*.[jt]s?(x)' ],
testPathIgnorePatterns: [
Expand All @@ -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.

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: [
Expand Down
17 changes: 17 additions & 0 deletions jest_setup.js
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(
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.

'./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(),
} )
);
Loading