diff --git a/packages/react-devtools-shared/src/__tests__/utils.js b/packages/react-devtools-shared/src/__tests__/utils.js index bf5a8b98ea..1a74c1fee9 100644 --- a/packages/react-devtools-shared/src/__tests__/utils.js +++ b/packages/react-devtools-shared/src/__tests__/utils.js @@ -19,7 +19,9 @@ export function act( recursivelyFlush: boolean = true, ): void { const {act: actTestRenderer} = require('react-test-renderer'); - const actDOM = require('react').unstable_act; + // Use `require('react-dom/test-utils').act` as a fallback for React 17, which can be used in integration tests for React DevTools. + const actDOM = + require('react').unstable_act || require('react-dom/test-utils').act; actDOM(() => { actTestRenderer(() => { @@ -44,7 +46,9 @@ export async function actAsync( recursivelyFlush: boolean = true, ): Promise { const {act: actTestRenderer} = require('react-test-renderer'); - const actDOM = require('react').unstable_act; + // Use `require('react-dom/test-utils').act` as a fallback for React 17, which can be used in integration tests for React DevTools. + const actDOM = + require('react').unstable_act || require('react-dom/test-utils').act; await actDOM(async () => { await actTestRenderer(async () => {