2
2
* @jest -environment jsdom
3
3
*/
4
4
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'
8
6
9
7
import Hello from '../components/hello'
10
8
11
9
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
- } )
24
10
; ( process . env . TURBOPACK_BUILD ? describe . skip : describe ) (
25
11
'development mode' ,
26
12
( ) => {
27
13
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 /> )
37
15
38
16
expect ( container . textContent ) . toBe ( 'Click me' )
39
17
} )
@@ -44,15 +22,7 @@ describe('Link without a router', () => {
44
22
( ) => {
45
23
// eslint-disable-next-line jest/no-identical-title
46
24
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 /> )
56
26
57
27
expect ( container . textContent ) . toBe ( 'Click me' )
58
28
} )
0 commit comments