Skip to content

Commit 59eed81

Browse files
authored
[email protected], @testing-library/react@15, Node.js 22 (adazzle#3500)
* [email protected], @testing-library/react@15 * import act from tsl * adopt Node.js 22 * fix rollup build
1 parent c15ee34 commit 59eed81

19 files changed

+52
-74
lines changed

.eslintrc.cjs

-5
Original file line numberDiff line numberDiff line change
@@ -681,11 +681,6 @@ const rules = {
681681
name: '@testing-library/dom',
682682
message: 'Import @testing-library/react instead.'
683683
},
684-
{
685-
name: '@testing-library/react',
686-
importNames: ['render'],
687-
message: 'Use the render helper from test/utils instead.'
688-
},
689684
{
690685
name: 'lodash',
691686
message: 'Import lodash-es instead.'

.github/workflows/ci.yml

+10-10
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- uses: actions/checkout@v4
1717
- uses: actions/setup-node@v4
1818
with:
19-
node-version: '21.x'
19+
node-version: '22.x'
2020
check-latest: true
2121
- uses: actions/cache@v4
2222
with:
@@ -25,19 +25,19 @@ jobs:
2525
- name: npm install
2626
run: npm i
2727
- name: Biome
28-
run: npm run biome:ci
28+
run: node --run biome:ci
2929
- name: ESLint
30-
run: npm run eslint
30+
run: node --run eslint
3131
- name: Prettier
32-
run: npm run prettier:check
32+
run: node --run prettier:check
3333
- name: Typecheck
34-
run: npm run typecheck
34+
run: node --run typecheck
3535
- name: Bundle
3636
run: |
37-
npm run build
38-
npm run build:types
37+
node --run build
38+
node --run build:types
3939
- name: Test
40-
run: npm t
40+
run: npm --run test
4141
timeout-minutes: 4
4242
- name: Upload coverage
4343
uses: codecov/codecov-action@v4
@@ -50,7 +50,7 @@ jobs:
5050
- uses: actions/checkout@v4
5151
- uses: actions/setup-node@v4
5252
with:
53-
node-version: '21.x'
53+
node-version: '22.x'
5454
check-latest: true
5555
- uses: actions/cache@v4
5656
with:
@@ -63,7 +63,7 @@ jobs:
6363
- name: Build
6464
run: |
6565
npm i
66-
npm run build:website
66+
node --run build:website
6767
- name: Set up git user
6868
if: github.event_name == 'push'
6969
run: |

package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@
4444
"check": "biome check . --error-on-warnings",
4545
"biome:ci": "biome ci . --error-on-warnings",
4646
"eslint": "eslint --ext js,ts,tsx --max-warnings 0 --cache --color src test website vite.config.ts",
47-
"eslint:fix": "npm run eslint -- --fix",
47+
"eslint:fix": "node --run eslint -- --fix",
4848
"prettier:check": "prettier --check .",
4949
"prettier:format": "prettier --write .",
5050
"typecheck": "tsc",
51-
"prepublishOnly": "npm install && npm run build && npm run build:types",
51+
"prepublishOnly": "npm install && node --run build && node --run build:types",
5252
"postpublish": "git push --follow-tags origin HEAD"
5353
},
5454
"dependencies": {
@@ -69,12 +69,12 @@
6969
"@rollup/plugin-babel": "^6.0.3",
7070
"@rollup/plugin-node-resolve": "^15.1.0",
7171
"@testing-library/jest-dom": "^6.2.0",
72-
"@testing-library/react": "^14.1.2",
72+
"@testing-library/react": "^15.0.5",
7373
"@testing-library/user-event": "^14.5.2",
7474
"@types/lodash-es": "^4.17.7",
7575
"@types/node": "^20.10.3",
76-
"@types/react": "^18.2.35",
77-
"@types/react-dom": "^18.2.4",
76+
"@types/react": "^18.3.0",
77+
"@types/react-dom": "^18.3.0",
7878
"@typescript-eslint/eslint-plugin": "^7.0.1",
7979
"@typescript-eslint/parser": "^7.0.1",
8080
"@vitejs/plugin-react": "^4.2.1",
@@ -88,7 +88,7 @@
8888
"eslint-plugin-jest-dom": "^5.0.1",
8989
"eslint-plugin-node": "^11.1.0",
9090
"eslint-plugin-react": "^7.32.2",
91-
"eslint-plugin-react-hooks": "^4.6.0",
91+
"eslint-plugin-react-hooks": "^4.6.2",
9292
"eslint-plugin-sonarjs": "^0.25.1",
9393
"eslint-plugin-testing-library": "^6.2.0",
9494
"jsdom": "^24.0.0",
@@ -97,10 +97,10 @@
9797
"lodash-es": "^4.17.21",
9898
"postcss": "^8.4.25",
9999
"prettier": "3.2.5",
100-
"react": "^18.1.0",
100+
"react": "^18.3.1",
101101
"react-dnd": "^16.0.1",
102102
"react-dnd-html5-backend": "^16.0.1",
103-
"react-dom": "^18.1.0",
103+
"react-dom": "^18.3.1",
104104
"react-router-dom": "^6.11.1",
105105
"rollup": "^4.0.2",
106106
"rollup-plugin-postcss": "^4.0.2",

rollup.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import wyw from '@wyw-in-js/rollup';
33
import postcss from 'rollup-plugin-postcss';
44
import { babel } from '@rollup/plugin-babel';
55
import nodeResolve from '@rollup/plugin-node-resolve';
6-
import pkg from './package.json' assert { type: 'json' };
6+
import pkg from './package.json' with { type: 'json' };
77

88
const extensions = ['.ts', '.tsx'];
99

test/TextEditor.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { useState } from 'react';
2-
import { fireEvent, screen } from '@testing-library/react';
2+
import { fireEvent, render, screen } from '@testing-library/react';
33
import userEvent from '@testing-library/user-event';
44

55
import DataGrid, { textEditor } from '../src';
66
import type { Column } from '../src';
7-
import { getCells, render } from './utils';
7+
import { getCells } from './utils';
88

99
interface Row {
1010
readonly name: string;

test/TreeDataGrid.test.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState } from 'react';
2-
import { screen, within } from '@testing-library/react';
2+
import { render, screen, within } from '@testing-library/react';
33
import userEvent from '@testing-library/user-event';
44
import { groupBy as rowGrouper } from 'lodash-es';
55

@@ -15,8 +15,7 @@ import {
1515
getRows,
1616
getSelectedCell,
1717
getTreeGrid,
18-
pasteSelectedCell,
19-
render
18+
pasteSelectedCell
2019
} from './utils';
2120

2221
const rowSelectedClassname = 'rdg-row-selected';

test/column/renderCell.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { useState } from 'react';
2-
import { screen } from '@testing-library/react';
2+
import { render, screen } from '@testing-library/react';
33
import userEvent from '@testing-library/user-event';
44

55
import DataGrid from '../../src';
66
import type { Column } from '../../src';
7-
import { getCells, getCellsAtRowIndex, render, setup } from '../utils';
7+
import { getCells, getCellsAtRowIndex, setup } from '../utils';
88

99
interface Row {
1010
id: number;

test/column/renderEditCell.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { useMemo, useState } from 'react';
22
import { createPortal } from 'react-dom';
3-
import { act, screen, waitFor } from '@testing-library/react';
3+
import { act, render, screen, waitFor } from '@testing-library/react';
44
import userEvent from '@testing-library/user-event';
55

66
import DataGrid from '../../src';
77
import type { Column, DataGridProps } from '../../src';
8-
import { getCellsAtRowIndex, getSelectedCell, render, scrollGrid } from '../utils';
8+
import { getCellsAtRowIndex, getSelectedCell, scrollGrid } from '../utils';
99

1010
interface Row {
1111
col1: number;

test/columnOrder.test.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import { render } from '@testing-library/react';
2+
13
import DataGrid, { SelectColumn, TreeDataGrid } from '../src';
24
import type { Column } from '../src';
3-
import { getHeaderCells, render } from './utils';
5+
import { getHeaderCells } from './utils';
46

57
const frozen1: Column<unknown> = {
68
key: 'f1',

test/copyPaste.test.tsx

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
import { useState } from 'react';
2+
import { render } from '@testing-library/react';
23
import userEvent from '@testing-library/user-event';
34

45
import DataGrid from '../src';
56
import type { Column, PasteEvent } from '../src';
6-
import {
7-
copySelectedCell,
8-
getCellsAtRowIndex,
9-
getSelectedCell,
10-
pasteSelectedCell,
11-
render
12-
} from './utils';
7+
import { copySelectedCell, getCellsAtRowIndex, getSelectedCell, pasteSelectedCell } from './utils';
138

149
interface Row {
1510
col: string;

test/dragFill.test.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { useState } from 'react';
2+
import { render } from '@testing-library/react';
23
import userEvent from '@testing-library/user-event';
34

45
import DataGrid from '../src';
56
import type { Column, FillEvent } from '../src';
6-
import { getCellsAtRowIndex, getRows, render } from './utils';
7+
import { getCellsAtRowIndex, getRows } from './utils';
78

89
interface Row {
910
col: string;

test/events.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { screen } from '@testing-library/react';
1+
import { render, screen } from '@testing-library/react';
22
import userEvent from '@testing-library/user-event';
33

44
import DataGrid from '../src';
55
import type { Column, DataGridProps } from '../src';
6-
import { getCellsAtRowIndex, render } from './utils';
6+
import { getCellsAtRowIndex } from './utils';
77

88
interface Row {
99
col1: number;

test/keyboardNavigation.test.tsx

+3-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import { StrictMode } from 'react';
1+
import { render } from '@testing-library/react';
22
import userEvent from '@testing-library/user-event';
33

44
import type { Column } from '../src';
55
import DataGrid, { SelectColumn } from '../src';
66
import {
77
getCellsAtRowIndex,
88
getSelectedCell,
9-
render,
109
scrollGrid,
1110
setup,
1211
validateCellPosition
@@ -294,11 +293,7 @@ test('reset selected cell when column is removed', async () => {
294293
await userEvent.keyboard('{arrowdown}{arrowright}');
295294
validateCellPosition(1, 1);
296295

297-
rerender(
298-
<StrictMode>
299-
<Test columns={[columns[0]]} />
300-
</StrictMode>
301-
);
296+
rerender(<Test columns={[columns[0]]} />);
302297

303298
expect(getSelectedCell()).not.toBeInTheDocument();
304299
});
@@ -320,11 +315,7 @@ test('reset selected cell when row is removed', async () => {
320315
await userEvent.keyboard('{arrowdown}{arrowdown}{arrowright}');
321316
validateCellPosition(1, 2);
322317

323-
rerender(
324-
<StrictMode>
325-
<Test rows={[rows[0]]} />
326-
</StrictMode>
327-
);
318+
rerender(<Test rows={[rows[0]]} />);
328319

329320
expect(getSelectedCell()).not.toBeInTheDocument();
330321
});

test/renderers.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { useState } from 'react';
2-
import { screen } from '@testing-library/react';
2+
import { render, screen } from '@testing-library/react';
33
import userEvent from '@testing-library/user-event';
44

55
import DataGrid, { DataGridDefaultRenderersProvider, renderSortIcon, SelectColumn } from '../src';
66
import type { Column, DataGridProps, RenderSortStatusProps, SortColumn } from '../src';
7-
import { getHeaderCells, getRows, render, setup } from './utils';
7+
import { getHeaderCells, getRows, setup } from './utils';
88

99
interface Row {
1010
id: number;

test/rowSelection.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { useState } from 'react';
2-
import { screen, within } from '@testing-library/react';
2+
import { render, screen, within } from '@testing-library/react';
33
import userEvent from '@testing-library/user-event';
44

55
import DataGrid, { SelectColumn } from '../src';
66
import type { Column } from '../src';
7-
import { getCellsAtRowIndex, getRows, render } from './utils';
7+
import { getCellsAtRowIndex, getRows } from './utils';
88

99
interface Row {
1010
id: number;

test/scrollToCell.test.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { useRef } from 'react';
2-
import { screen } from '@testing-library/react';
2+
import { render, screen } from '@testing-library/react';
33
import userEvent from '@testing-library/user-event';
44

55
import type { Column, DataGridHandle } from '../src';
66
import DataGrid from '../src';
77
import type { PartialPosition } from '../src/ScrollToCell';
8-
import { render } from './utils';
98

109
type Row = undefined;
1110

test/setup.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { act } from 'react-dom/test-utils';
2-
import { configure } from '@testing-library/react';
1+
import { act, configure } from '@testing-library/react';
32

4-
configure({ throwSuggestions: true });
3+
configure({
4+
reactStrictMode: true,
5+
throwSuggestions: true
6+
});
57

68
// Allow node-environment tests to properly fail when accessing DOM APIs,
79
// as @testing-library/jest-dom may polyfill some DOM APIs like `window.CSS`

test/sorting.test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { useState } from 'react';
2-
import { screen } from '@testing-library/react';
2+
import { render, screen } from '@testing-library/react';
33
import userEvent from '@testing-library/user-event';
44

55
import DataGrid from '../src';
66
import type { Column, SortColumn } from '../src/types';
7-
import { getHeaderCells, render } from './utils';
7+
import { getHeaderCells } from './utils';
88

99
const columns: readonly Column<unknown>[] = [
1010
{ key: 'colA', name: 'colA' },

test/utils.tsx

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
import { StrictMode } from 'react';
2-
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
3-
import { act, fireEvent, render as rtlRender, screen } from '@testing-library/react';
1+
import { act, fireEvent, render, screen } from '@testing-library/react';
42

53
import DataGrid from '../src/';
64
import type { DataGridProps } from '../src/';
75

8-
export function render(child: React.ReactElement) {
9-
return rtlRender(<StrictMode>{child}</StrictMode>);
10-
}
11-
126
export function setup<R, SR, K extends React.Key>(props: DataGridProps<R, SR, K>) {
137
return render(<DataGrid {...props} />);
148
}

0 commit comments

Comments
 (0)