File tree 3 files changed +8
-8
lines changed
3 files changed +8
-8
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react'
2
2
import { render , cleanup } from '../'
3
3
4
- test ( 'cleans up the document' , ( ) => {
4
+ test ( 'cleans up the document' , async ( ) => {
5
5
const spy = jest . fn ( )
6
6
const divId = 'my-div'
7
7
@@ -17,12 +17,12 @@ test('cleans up the document', () => {
17
17
}
18
18
19
19
render ( < Test /> )
20
- cleanup ( )
20
+ await cleanup ( )
21
21
expect ( document . body . innerHTML ) . toBe ( '' )
22
22
expect ( spy ) . toHaveBeenCalledTimes ( 1 )
23
23
} )
24
24
25
- test ( 'cleanup does not error when an element is not a child' , ( ) => {
25
+ test ( 'cleanup does not error when an element is not a child' , async ( ) => {
26
26
render ( < div /> , { container : document . createElement ( 'div' ) } )
27
- cleanup ( )
27
+ await cleanup ( )
28
28
} )
Original file line number Diff line number Diff line change 1
- import flush from './flush-microtasks'
2
1
import { cleanup } from './pure'
3
2
4
3
// if we're running in a test runner that supports afterEach
@@ -8,8 +7,7 @@ import {cleanup} from './pure'
8
7
// or set the RTL_SKIP_AUTO_CLEANUP env variable to 'true'.
9
8
if ( typeof afterEach === 'function' && ! process . env . RTL_SKIP_AUTO_CLEANUP ) {
10
9
afterEach ( async ( ) => {
11
- await flush ( )
12
- cleanup ( )
10
+ await cleanup ( )
13
11
} )
14
12
}
15
13
Original file line number Diff line number Diff line change 7
7
configure as configureDTL ,
8
8
} from '@testing-library/dom'
9
9
import act , { asyncAct } from './act-compat'
10
+ import flush from './flush-microtasks'
10
11
11
12
configureDTL ( {
12
13
asyncWrapper : async cb => {
@@ -88,7 +89,8 @@ function render(
88
89
}
89
90
}
90
91
91
- function cleanup ( ) {
92
+ async function cleanup ( ) {
93
+ await flush ( )
92
94
mountedContainers . forEach ( cleanupAtContainer )
93
95
}
94
96
You can’t perform that action at this time.
0 commit comments