Skip to content

Commit 0f62e27

Browse files
committed
test: replace deprecated use of TestRenderer.create with @testing-library/react
1 parent 99c8a67 commit 0f62e27

34 files changed

+6578
-3216
lines changed

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@
132132
"@types/nprogress": "0.2.3",
133133
"@types/react": "18.3.2",
134134
"@types/react-router-dom": "5.3.3",
135-
"@types/react-test-renderer": "18.3.0",
136135
"@types/react-transition-group": "4.4.10",
137136
"autoprefixer": "10.4.19",
138137
"css-loader": "7.1.1",
@@ -145,7 +144,6 @@
145144
"nock": "13.5.4",
146145
"postcss": "8.4.38",
147146
"postcss-loader": "8.1.1",
148-
"react-test-renderer": "18.3.1",
149147
"rimraf": "5.0.7",
150148
"style-loader": "4.0.0",
151149
"tailwindcss": "3.4.3",

pnpm-lock.yaml

Lines changed: 0 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/AccountNotifications.test.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import TestRenderer from 'react-test-renderer';
2-
1+
import { render } from '@testing-library/react';
32
import { mockedGitHubNotifications } from '../__mocks__/mockedData';
43
import { AccountNotifications } from './AccountNotifications';
54

@@ -15,7 +14,7 @@ describe('components/AccountNotifications.tsx', () => {
1514
showAccountHostname: true,
1615
};
1716

18-
const tree = TestRenderer.create(<AccountNotifications {...props} />);
17+
const tree = render(<AccountNotifications {...props} />);
1918
expect(tree).toMatchSnapshot();
2019
});
2120

@@ -26,7 +25,7 @@ describe('components/AccountNotifications.tsx', () => {
2625
showAccountHostname: true,
2726
};
2827

29-
const tree = TestRenderer.create(<AccountNotifications {...props} />);
28+
const tree = render(<AccountNotifications {...props} />);
3029
expect(tree).toMatchSnapshot();
3130
});
3231
});

src/components/AllRead.test.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import * as TestRenderer from 'react-test-renderer';
2-
31
import { mockMathRandom } from './test-utils';
42

3+
import { render } from '@testing-library/react';
54
import { AllRead } from './AllRead';
65

76
describe('components/AllRead.tsx', () => {
@@ -10,7 +9,7 @@ describe('components/AllRead.tsx', () => {
109
mockMathRandom(0.1);
1110

1211
it('should render itself & its children', () => {
13-
const tree = TestRenderer.create(<AllRead />);
12+
const tree = render(<AllRead />);
1413

1514
expect(tree).toMatchSnapshot();
1615
});

src/components/Logo.test.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
import { fireEvent, render, screen } from '@testing-library/react';
22

3-
import * as TestRenderer from 'react-test-renderer';
4-
53
import { Logo } from './Logo';
64

75
describe('components/Logo.tsx', () => {
86
it('renders correctly (light)', () => {
9-
const tree = TestRenderer.create(<Logo />);
7+
const tree = render(<Logo />);
108

119
expect(tree).toMatchSnapshot();
1210
});
1311

1412
it('renders correctly(dark)', () => {
15-
const tree = TestRenderer.create(<Logo isDark />);
13+
const tree = render(<Logo isDark />);
1614

1715
expect(tree).toMatchSnapshot();
1816
});

src/components/NotificationRow.test.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { fireEvent, render, screen } from '@testing-library/react';
22

3-
import * as TestRenderer from 'react-test-renderer';
4-
53
import * as helpers from '../utils/helpers';
64

75
import { shell } from 'electron';
@@ -30,7 +28,7 @@ describe('components/NotificationRow.tsx', () => {
3028
hostname: 'github.com',
3129
};
3230

33-
const tree = TestRenderer.create(<NotificationRow {...props} />);
31+
const tree = render(<NotificationRow {...props} />);
3432
expect(tree).toMatchSnapshot();
3533
});
3634

@@ -47,7 +45,7 @@ describe('components/NotificationRow.tsx', () => {
4745
hostname: 'github.com',
4846
};
4947

50-
const tree = TestRenderer.create(<NotificationRow {...props} />);
48+
const tree = render(<NotificationRow {...props} />);
5149
expect(tree).toMatchSnapshot();
5250
});
5351

@@ -64,7 +62,7 @@ describe('components/NotificationRow.tsx', () => {
6462
hostname: 'github.com',
6563
};
6664

67-
const tree = TestRenderer.create(<NotificationRow {...props} />);
65+
const tree = render(<NotificationRow {...props} />);
6866
expect(tree).toMatchSnapshot();
6967
});
7068

@@ -82,7 +80,7 @@ describe('components/NotificationRow.tsx', () => {
8280
hostname: 'github.com',
8381
};
8482

85-
const tree = TestRenderer.create(<NotificationRow {...props} />);
83+
const tree = render(<NotificationRow {...props} />);
8684
expect(tree).toMatchSnapshot();
8785
});
8886

@@ -99,7 +97,7 @@ describe('components/NotificationRow.tsx', () => {
9997
hostname: 'github.com',
10098
};
10199

102-
const tree = TestRenderer.create(<NotificationRow {...props} />);
100+
const tree = render(<NotificationRow {...props} />);
103101
expect(tree).toMatchSnapshot();
104102
});
105103

@@ -116,7 +114,7 @@ describe('components/NotificationRow.tsx', () => {
116114
hostname: 'github.com',
117115
};
118116

119-
const tree = TestRenderer.create(<NotificationRow {...props} />);
117+
const tree = render(<NotificationRow {...props} />);
120118
expect(tree).toMatchSnapshot();
121119
});
122120
});

src/components/Oops.test.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import * as TestRenderer from 'react-test-renderer';
2-
1+
import { render } from '@testing-library/react';
32
import { Oops } from './Oops';
43

54
describe('components/Oops.tsx', () => {
@@ -9,7 +8,7 @@ describe('components/Oops.tsx', () => {
98
descriptions: ['Error description'],
109
emojis: ['🔥'],
1110
};
12-
const tree = TestRenderer.create(<Oops error={mockError} />);
11+
const tree = render(<Oops error={mockError} />);
1312

1413
expect(tree).toMatchSnapshot();
1514
});

src/components/Repository.test.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { fireEvent, render, screen } from '@testing-library/react';
2-
import TestRenderer from 'react-test-renderer';
32
import { mockedGitHubNotifications } from '../__mocks__/mockedData';
43
import { AppContext } from '../context/App';
54
import { RepositoryNotifications } from './Repository';
@@ -26,7 +25,7 @@ describe('components/Repository.tsx', () => {
2625
});
2726

2827
it('should render itself & its children', () => {
29-
const tree = TestRenderer.create(
28+
const tree = render(
3029
<AppContext.Provider value={{}}>
3130
<RepositoryNotifications {...props} />
3231
</AppContext.Provider>,
@@ -82,7 +81,7 @@ describe('components/Repository.tsx', () => {
8281
it('should use default repository icon when avatar is not available', () => {
8382
props.repoNotifications[0].repository.owner.avatar_url = '';
8483

85-
const tree = TestRenderer.create(
84+
const tree = render(
8685
<AppContext.Provider value={{}}>
8786
<RepositoryNotifications {...props} />
8887
</AppContext.Provider>,

src/components/Sidebar.test.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { fireEvent, render, screen } from '@testing-library/react';
22
import { MemoryRouter } from 'react-router-dom';
3-
import * as TestRenderer from 'react-test-renderer';
43
const { shell, ipcRenderer } = require('electron');
54
import { mockSettings } from '../__mocks__/mock-state';
65
import { mockedAccountNotifications } from '../__mocks__/mockedData';
@@ -29,7 +28,7 @@ describe('components/Sidebar.tsx', () => {
2928
});
3029

3130
it('should render itself & its children (logged in)', () => {
32-
const tree = TestRenderer.create(
31+
const tree = render(
3332
<AppContext.Provider
3433
value={{
3534
settings: mockSettings,
@@ -45,7 +44,7 @@ describe('components/Sidebar.tsx', () => {
4544
});
4645

4746
it('should render itself & its children (logged out)', () => {
48-
const tree = TestRenderer.create(
47+
const tree = render(
4948
<AppContext.Provider
5049
value={{ isLoggedIn: false, notifications: mockedAccountNotifications }}
5150
>

0 commit comments

Comments
 (0)