forked from testing-library/react-testing-library
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Use concurrent React when available (testing-library#937)
BREAKING CHANGE: If you have React 18 installed, we'll use the new [`createRoot` API](reactwg/react-18#5) by default which comes with a set of [changes while also enabling support for concurrent features](reactwg/react-18#4). To can opt-out of this change by using `render(ui, { legacyRoot: true } )`. But be aware that the legacy root API is deprecated in React 18 and its usage will trigger console warnings.
- Loading branch information
Showing
14 changed files
with
210 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const {jest: jestConfig} = require('kcd-scripts/config') | ||
|
||
module.exports = Object.assign(jestConfig, { | ||
coverageThreshold: { | ||
...jestConfig.coverageThreshold, | ||
// full coverage across the build matrix (React 17, 18) but not in a single job | ||
'./src/pure': { | ||
// minimum coverage of jobs using React 17 and 18 | ||
branches: 80, | ||
functions: 78, | ||
lines: 84, | ||
statements: 84, | ||
}, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,9 @@ import * as React from 'react' | |
import ReactDOM from 'react-dom' | ||
import * as testUtils from 'react-dom/test-utils' | ||
|
||
const reactAct = testUtils.act | ||
const actSupported = reactAct !== undefined | ||
const isomorphicAct = React.unstable_act | ||
const domAct = testUtils.act | ||
const actSupported = domAct !== undefined | ||
|
||
// act is supported [email protected] | ||
// so for versions that don't have act from test utils | ||
|
@@ -14,7 +15,7 @@ function actPolyfill(cb) { | |
ReactDOM.render(<div />, document.createElement('div')) | ||
} | ||
|
||
const act = reactAct || actPolyfill | ||
const act = isomorphicAct || domAct || actPolyfill | ||
|
||
let youHaveBeenWarned = false | ||
let isAsyncActSupported = null | ||
|
@@ -50,7 +51,7 @@ function asyncAct(cb) { | |
} | ||
let cbReturn, result | ||
try { | ||
result = reactAct(() => { | ||
result = domAct(() => { | ||
cbReturn = cb() | ||
return cbReturn | ||
}) | ||
|
Oops, something went wrong.