Skip to content

Commit 3755598

Browse files
committed
Use @testing-library instead of react-dom/test-utils
1 parent ac3c683 commit 3755598

File tree

1 file changed

+3
-33
lines changed

1 file changed

+3
-33
lines changed

test/integration/link-without-router/test/index.test.js

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,16 @@
22
* @jest-environment jsdom
33
*/
44
import React from 'react'
5-
// eslint-disable-next-line react/no-deprecated
6-
import { render, unmountComponentAtNode } from 'react-dom'
7-
import { act } from 'react-dom/test-utils'
5+
import { render } from '@testing-library/react'
86

97
import Hello from '../components/hello'
108

119
describe('Link without a router', () => {
12-
let container = null
13-
14-
beforeEach(() => {
15-
container = document.createElement('div')
16-
document.body.appendChild(container)
17-
})
18-
19-
afterEach(() => {
20-
unmountComponentAtNode(container)
21-
container.remove()
22-
container = null
23-
})
2410
;(process.env.TURBOPACK_BUILD ? describe.skip : describe)(
2511
'development mode',
2612
() => {
2713
it('should not throw when rendered', () => {
28-
jest.useFakeTimers()
29-
30-
act(() => {
31-
render(<Hello />, container)
32-
})
33-
34-
act(() => {
35-
jest.runAllTimers()
36-
})
14+
const { container } = render(<Hello />)
3715

3816
expect(container.textContent).toBe('Click me')
3917
})
@@ -44,15 +22,7 @@ describe('Link without a router', () => {
4422
() => {
4523
// eslint-disable-next-line jest/no-identical-title
4624
it('should not throw when rendered', () => {
47-
jest.useFakeTimers()
48-
49-
act(() => {
50-
render(<Hello />, container)
51-
})
52-
53-
act(() => {
54-
jest.runAllTimers()
55-
})
25+
const { container } = render(<Hello />)
5626

5727
expect(container.textContent).toBe('Click me')
5828
})

0 commit comments

Comments
 (0)