@@ -4,18 +4,13 @@ import {
4
4
getQueriesForElement ,
5
5
prettyDOM ,
6
6
configure as configureDTL ,
7
+ waitFor as waitForDTL ,
8
+ waitForElementToBeRemoved as waitForElementToBeRemovedDTL ,
7
9
} from '@testing-library/dom'
8
10
import act , { asyncAct } from './act-compat'
9
11
import { fireEvent } from './fire-event'
10
12
11
13
configureDTL ( {
12
- asyncWrapper : async cb => {
13
- let result
14
- await asyncAct ( async ( ) => {
15
- result = await cb ( )
16
- } )
17
- return result
18
- } ,
19
14
eventWrapper : cb => {
20
15
let result
21
16
act ( ( ) => {
@@ -197,9 +192,29 @@ function cleanup() {
197
192
mountedContainers . clear ( )
198
193
}
199
194
195
+ function waitFor ( callback , options ) {
196
+ return waitForDTL ( ( ) => {
197
+ let result
198
+ act ( ( ) => {
199
+ result = callback ( )
200
+ } )
201
+ return result
202
+ } , options )
203
+ }
204
+
205
+ function waitForElementToBeRemoved ( callback , options ) {
206
+ return waitForElementToBeRemovedDTL ( ( ) => {
207
+ let result
208
+ act ( ( ) => {
209
+ result = callback ( )
210
+ } )
211
+ return result
212
+ } , options )
213
+ }
214
+
200
215
// just re-export everything from dom-testing-library
201
216
export * from '@testing-library/dom'
202
- export { render , cleanup , act , fireEvent }
217
+ export { render , cleanup , act , fireEvent , waitFor , waitForElementToBeRemoved }
203
218
204
219
// NOTE: we're not going to export asyncAct because that's our own compatibility
205
220
// thing for people using react-dom@16.8.0. Anyone else doesn't need it and
0 commit comments