Skip to content

Commit d8f6c91

Browse files
committed
Use advanceTimersWrapper
1 parent a20aa57 commit d8f6c91

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"license": "MIT",
4545
"dependencies": {
4646
"@babel/runtime": "^7.12.5",
47-
"@testing-library/dom": "^8.0.0"
47+
"@testing-library/dom": "https://pkg.csb.dev/testing-library/dom-testing-library/commit/9d12234d/@testing-library/dom"
4848
},
4949
"devDependencies": {
5050
"@testing-library/jest-dom": "^5.11.6",

src/pure.js

+10-13
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ import {
44
getQueriesForElement,
55
prettyDOM,
66
configure as configureDTL,
7-
waitForElementToBeRemoved as waitForElementToBeRemovedDTL,
87
} from '@testing-library/dom'
98
import act from './act-compat'
109
import {fireEvent} from './fire-event'
11-
import {waitFor} from './wait-for'
1210

1311
configureDTL({
1412
eventWrapper: cb => {
@@ -20,6 +18,15 @@ configureDTL({
2018
},
2119
})
2220

21+
if (typeof React.startTransition !== undefined) {
22+
configureDTL({
23+
unstable_advanceTimersWrapper: cb => {
24+
return act(cb)
25+
},
26+
asyncWrapper: cb => cb(),
27+
})
28+
}
29+
2330
// Ideally we'd just use a WeakMap where containers are keys and roots are values.
2431
// We use two variables so that we can bail out in constant time when we render with a new container (most common use case)
2532
/**
@@ -192,19 +199,9 @@ function cleanup() {
192199
mountedContainers.clear()
193200
}
194201

195-
function waitForElementToBeRemoved(callback, options) {
196-
return waitForElementToBeRemovedDTL(() => {
197-
let result
198-
act(() => {
199-
result = callback()
200-
})
201-
return result
202-
}, options)
203-
}
204-
205202
// just re-export everything from dom-testing-library
206203
export * from '@testing-library/dom'
207-
export {render, cleanup, act, fireEvent, waitFor, waitForElementToBeRemoved}
204+
export {render, cleanup, act, fireEvent}
208205

209206
// NOTE: we're not going to export asyncAct because that's our own compatibility
210207
// thing for people using [email protected]. Anyone else doesn't need it and

0 commit comments

Comments
 (0)