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

chore: Adjust tests to workaround 18.3.0 bug #1315

Merged
merged 1 commit into from Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -56,8 +56,8 @@
"jest-diff": "^29.7.0",
"kcd-scripts": "^13.0.0",
"npm-run-all": "^4.1.5",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react": "^18.3.0",
"react-dom": "^18.3.0",
"rimraf": "^3.0.2",
"typescript": "^4.1.2"
},
Expand Down
3 changes: 0 additions & 3 deletions src/__tests__/stopwatch.js
Expand Up @@ -40,7 +40,6 @@ class StopWatch extends React.Component {
const sleep = t => new Promise(resolve => setTimeout(resolve, t))

test('unmounts a component', async () => {
jest.spyOn(console, 'error').mockImplementation(() => {})
const {unmount, container} = render(<StopWatch />)
fireEvent.click(screen.getByText('Start'))
unmount()
Expand All @@ -52,6 +51,4 @@ test('unmounts a component', async () => {
// if it's not, then we'll call setState on an unmounted component
// and get an error.
await sleep(5)
// eslint-disable-next-line no-console
expect(console.error).not.toHaveBeenCalled()
})
9 changes: 9 additions & 0 deletions tests/shouldIgnoreConsoleError.js
Expand Up @@ -36,6 +36,15 @@ module.exports = function shouldIgnoreConsoleError(format) {
// Ignore it too.
return true
}
if (
format.startsWith(
'Warning: `ReactDOMTestUtils.act` is deprecated in favor of `React.act`.',
)
) {
// This is a React bug in 18.3.0.
// Versions with `ReactDOMTestUtils.ac` being deprecated, should have `React.act`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really minor, sorry:

Suggested change
// Versions with `ReactDOMTestUtils.ac` being deprecated, should have `React.act`
// Versions with `ReactDOMTestUtils.act` being deprecated, should have `React.act`

return true
}
}
}
// Looks legit
Expand Down