File tree Expand file tree Collapse file tree 3 files changed +8
-8
lines changed Expand file tree Collapse file tree 3 files changed +8
-8
lines changed Original file line number Diff line number Diff line change 11import React from 'react'
22import { render , cleanup } from '../'
33
4- test ( 'cleans up the document' , ( ) => {
4+ test ( 'cleans up the document' , async ( ) => {
55 const spy = jest . fn ( )
66 const divId = 'my-div'
77
@@ -17,12 +17,12 @@ test('cleans up the document', () => {
1717 }
1818
1919 render ( < Test /> )
20- cleanup ( )
20+ await cleanup ( )
2121 expect ( document . body . innerHTML ) . toBe ( '' )
2222 expect ( spy ) . toHaveBeenCalledTimes ( 1 )
2323} )
2424
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 ( ) => {
2626 render ( < div /> , { container : document . createElement ( 'div' ) } )
27- cleanup ( )
27+ await cleanup ( )
2828} )
Original file line number Diff line number Diff line change 1- import flush from './flush-microtasks'
21import { cleanup } from './pure'
32
43// if we're running in a test runner that supports afterEach
@@ -8,8 +7,7 @@ import {cleanup} from './pure'
87// or set the RTL_SKIP_AUTO_CLEANUP env variable to 'true'.
98if ( typeof afterEach === 'function' && ! process . env . RTL_SKIP_AUTO_CLEANUP ) {
109 afterEach ( async ( ) => {
11- await flush ( )
12- cleanup ( )
10+ await cleanup ( )
1311 } )
1412}
1513
Original file line number Diff line number Diff line change 77 configure as configureDTL ,
88} from '@testing-library/dom'
99import act , { asyncAct } from './act-compat'
10+ import flush from './flush-microtasks'
1011
1112configureDTL ( {
1213 asyncWrapper : async cb => {
@@ -88,7 +89,8 @@ function render(
8889 }
8990}
9091
91- function cleanup ( ) {
92+ async function cleanup ( ) {
93+ await flush ( )
9294 mountedContainers . forEach ( cleanupAtContainer )
9395}
9496
You can’t perform that action at this time.
0 commit comments