Skip to content

Commit bbc7269

Browse files
authored
chore(monorepo): upgrade React packages to v19 (#11698)
Co-authored-by: slorber <[email protected]>
1 parent 81248ee commit bbc7269

File tree

34 files changed

+501
-465
lines changed

34 files changed

+501
-465
lines changed

jest.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default {
3535
// Default 5s timeout often fails on Windows :s,
3636
// see https://github.com/facebook/docusaurus/pull/8259
3737
testTimeout: 15000,
38-
setupFiles: ['./jest/setup.js'],
38+
setupFiles: ['./jest/setup.ts'],
3939
testEnvironmentOptions: {
4040
url: 'https://docusaurus.io/',
4141
},

jest/setup.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

jest/setup.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
// Currently not used anymore, but kept for potential future setup needs

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,15 @@
7979
"@prettier/plugin-xml": "^2.2.0",
8080
"@swc/core": "^1.7.14",
8181
"@swc/jest": "^0.2.39",
82-
"@testing-library/react-hooks": "^8.0.1",
82+
"@testing-library/dom": "^10.4.1",
83+
"@testing-library/jest-dom": "^6.9.1",
84+
"@testing-library/react": "^16.3.2",
8385
"@types/fs-extra": "^9.0.13",
8486
"@types/jest": "^30.0.0",
8587
"@types/lodash": "^4.14.197",
8688
"@types/node": "^18.16.19",
8789
"@types/prompts": "^2.4.4",
8890
"@types/react": "^19.2.10",
89-
"@types/react-test-renderer": "^18.0.0",
9091
"@types/semver": "^7.5.0",
9192
"@types/shelljs": "^0.8.12",
9293
"@typescript-eslint/eslint-plugin": "^5.62.0",
@@ -118,9 +119,8 @@
118119
"patch-package": "^8.0.0",
119120
"postinstall-postinstall": "^2.1.0",
120121
"prettier": "^2.8.8",
121-
"react": "^18.0.0",
122-
"react-dom": "^18.0.0",
123-
"react-test-renderer": "^18.0.0",
122+
"react": "^19.2.4",
123+
"react-dom": "^19.2.4",
124124
"rimraf": "^3.0.2",
125125
"sharp": "^0.32.3",
126126
"strip-ansi": "^6.0.1",
@@ -129,6 +129,8 @@
129129
"stylelint-config-standard": "^29.0.0",
130130
"typescript": "~5.8.2"
131131
},
132-
"resolutions": {},
132+
"resolutions": {
133+
"**/pretty-format/react-is": "^19.2.4"
134+
},
133135
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
134136
}

packages/docusaurus-plugin-content-docs/src/client/__tests__/docsSidebar.test.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
*
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @jest-environment jsdom
68
*/
79

10+
// Jest doesn't allow pragma below other comments. https://github.com/facebook/jest/issues/12573
11+
// eslint-disable-next-line header/header
812
import React from 'react';
9-
import {renderHook} from '@testing-library/react-hooks';
13+
import {renderHook} from '@testing-library/react';
1014
import {useDocsSidebar, DocsSidebarProvider} from '../docsSidebar';
1115
import type {PropSidebar} from '@docusaurus/plugin-content-docs';
1216

packages/docusaurus-plugin-content-docs/src/client/__tests__/docsUtils.test.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
*
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @jest-environment jsdom
68
*/
79

10+
// Jest doesn't allow pragma below other comments. https://github.com/facebook/jest/issues/12573
11+
// eslint-disable-next-line header/header
812
import React from 'react';
9-
import {renderHook} from '@testing-library/react-hooks';
13+
import {renderHook} from '@testing-library/react';
1014
import {StaticRouter} from 'react-router-dom';
1115
import {Context} from '@docusaurus/core/src/client/docusaurusContext';
1216
import {

packages/docusaurus-plugin-content-docs/src/client/__tests__/docsVersion.test.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
*
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @jest-environment jsdom
68
*/
79

10+
// Jest doesn't allow pragma below other comments. https://github.com/facebook/jest/issues/12573
11+
// eslint-disable-next-line header/header
812
import React from 'react';
9-
import {renderHook} from '@testing-library/react-hooks';
13+
import {renderHook} from '@testing-library/react';
1014
import {useDocsVersion, DocsVersionProvider} from '../docsVersion';
1115
import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs';
1216

packages/docusaurus-plugin-ideal-image/src/theme/IdealImageLegacy/__tests__/__snapshots__/icon.js.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
exports[`Download icon Should render a snapshot that is good 1`] = `
44
<svg
5-
height={24}
5+
height="24"
66
viewBox="0 0 24 24"
7-
width={24}
7+
width="24"
88
xmlns="http://www.w3.org/2000/svg"
99
>
1010
<path
@@ -20,9 +20,9 @@ exports[`Download icon Should render a snapshot that is good 1`] = `
2020

2121
exports[`Loading icon Should render a snapshot that is good 1`] = `
2222
<svg
23-
height={24}
23+
height="24"
2424
viewBox="0 0 24 24"
25-
width={24}
25+
width="24"
2626
xmlns="http://www.w3.org/2000/svg"
2727
>
2828
<path
@@ -38,9 +38,9 @@ exports[`Loading icon Should render a snapshot that is good 1`] = `
3838

3939
exports[`Offline icon Should render a snapshot that is good 1`] = `
4040
<svg
41-
height={24}
41+
height="24"
4242
viewBox="0 0 24 24"
43-
width={24}
43+
width="24"
4444
xmlns="http://www.w3.org/2000/svg"
4545
>
4646
<path
@@ -56,9 +56,9 @@ exports[`Offline icon Should render a snapshot that is good 1`] = `
5656

5757
exports[`Warning icon Should render a snapshot that is good 1`] = `
5858
<svg
59-
height={24}
59+
height="24"
6060
viewBox="0 0 24 24"
61-
width={24}
61+
width="24"
6262
xmlns="http://www.w3.org/2000/svg"
6363
>
6464
<path
Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
/**
2+
* @jest-environment jsdom
3+
*/
4+
15
import React from 'react';
2-
import renderer from 'react-test-renderer';
6+
import {render} from '@testing-library/react';
7+
import '@testing-library/jest-dom';
38
import Download from '../components/Icon/Download';
49
import Loading from '../components/Icon/Loading';
510
import Offline from '../components/Icon/Offline';
@@ -9,28 +14,28 @@ const snapshotTestDescription = 'Should render a snapshot that is good';
914

1015
describe('Download icon', () => {
1116
it(snapshotTestDescription, () => {
12-
const download = renderer.create(<Download />).toJSON();
13-
expect(download).toMatchSnapshot();
17+
const {container} = render(<Download />);
18+
expect(container.firstElementChild).toMatchSnapshot();
1419
});
1520
});
1621

1722
describe('Loading icon', () => {
1823
it(snapshotTestDescription, () => {
19-
const loading = renderer.create(<Loading />).toJSON();
20-
expect(loading).toMatchSnapshot();
24+
const {container} = render(<Loading />);
25+
expect(container.firstElementChild).toMatchSnapshot();
2126
});
2227
});
2328

2429
describe('Offline icon', () => {
2530
it(snapshotTestDescription, () => {
26-
const offline = renderer.create(<Offline />).toJSON();
27-
expect(offline).toMatchSnapshot();
31+
const {container} = render(<Offline />);
32+
expect(container.firstElementChild).toMatchSnapshot();
2833
});
2934
});
3035

3136
describe('Warning icon', () => {
3237
it(snapshotTestDescription, () => {
33-
const warning = renderer.create(<Warning />).toJSON();
34-
expect(warning).toMatchSnapshot();
38+
const {container} = render(<Warning />);
39+
expect(container.firstElementChild).toMatchSnapshot();
3540
});
3641
});

packages/docusaurus-theme-classic/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
"@types/prismjs": "^1.26.0",
5252
"@types/rtlcss": "^3.5.1",
5353
"fs-extra": "^11.1.1",
54-
"react-test-renderer": "^18.0.0",
5554
"utility-types": "^3.10.0"
5655
},
5756
"peerDependencies": {

0 commit comments

Comments
 (0)