Skip to content

Commit 14d5753

Browse files
committed
Use advanceTimersWrapper
1 parent 9938c9e commit 14d5753

File tree

5 files changed

+15
-312
lines changed

5 files changed

+15
-312
lines changed

jest.config.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ module.exports = Object.assign(jestConfig, {
66
// full coverage across the build matrix (React 17, 18) but not in a single job
77
'./src/pure': {
88
// minimum coverage of jobs using React 17 and 18
9-
branches: 82,
10-
functions: 76,
11-
lines: 81,
12-
statements: 81,
9+
branches: 80,
10+
functions: 84,
11+
lines: 89,
12+
statements: 89,
1313
},
1414
},
1515
})

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/dtlHelpers.js

-88
This file was deleted.

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

src/wait-for.js

-206
This file was deleted.

0 commit comments

Comments
 (0)