Skip to content

Commit f6a1677

Browse files
authored
chore: Adjust tests to workaround 18.3.0 bug (#1315)
1 parent d143f46 commit f6a1677

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656
"jest-diff": "^29.7.0",
5757
"kcd-scripts": "^13.0.0",
5858
"npm-run-all": "^4.1.5",
59-
"react": "^18.0.0",
60-
"react-dom": "^18.0.0",
59+
"react": "^18.3.0",
60+
"react-dom": "^18.3.0",
6161
"rimraf": "^3.0.2",
6262
"typescript": "^4.1.2"
6363
},

src/__tests__/stopwatch.js

-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class StopWatch extends React.Component {
4040
const sleep = t => new Promise(resolve => setTimeout(resolve, t))
4141

4242
test('unmounts a component', async () => {
43-
jest.spyOn(console, 'error').mockImplementation(() => {})
4443
const {unmount, container} = render(<StopWatch />)
4544
fireEvent.click(screen.getByText('Start'))
4645
unmount()
@@ -52,6 +51,4 @@ test('unmounts a component', async () => {
5251
// if it's not, then we'll call setState on an unmounted component
5352
// and get an error.
5453
await sleep(5)
55-
// eslint-disable-next-line no-console
56-
expect(console.error).not.toHaveBeenCalled()
5754
})

tests/shouldIgnoreConsoleError.js

+9
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ module.exports = function shouldIgnoreConsoleError(format) {
3636
// Ignore it too.
3737
return true
3838
}
39+
if (
40+
format.startsWith(
41+
'Warning: `ReactDOMTestUtils.act` is deprecated in favor of `React.act`.',
42+
)
43+
) {
44+
// This is a React bug in 18.3.0.
45+
// Versions with `ReactDOMTestUtils.ac` being deprecated, should have `React.act`
46+
return true
47+
}
3948
}
4049
}
4150
// Looks legit

0 commit comments

Comments
 (0)