Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e44adc5

Browse files
committedJun 12, 2021
test: Ignore React 18 legacy root deprecation warnings
1 parent 7957355 commit e44adc5

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
 

‎tests/setup-env.js

+20
Original file line numberDiff line numberDiff line change
@@ -1 +1,21 @@
11
import '@testing-library/jest-dom/extend-expect'
2+
3+
beforeEach(() => {
4+
const originalConsoleError = console.error
5+
jest
6+
.spyOn(console, 'error')
7+
.mockImplementation((message, ...optionalParams) => {
8+
// Ignore ReactDOM.render/ReactDOM.hydrate deprecation warning
9+
if (message.indexOf('Use createRoot instead.') !== -1) {
10+
return
11+
}
12+
originalConsoleError(message, ...optionalParams)
13+
})
14+
})
15+
16+
afterEach(() => {
17+
// maybe another test already restore console error mocks
18+
if (typeof console.error.mockRestore === 'function') {
19+
console.error.mockRestore()
20+
}
21+
})

0 commit comments

Comments
 (0)
Please sign in to comment.