Skip to content

Commit

Permalink
Update act references in tests (#27805)
Browse files Browse the repository at this point in the history
As part of the process of removing the deprecated `react-dom/test-utils`
package references to `act` from this module are replaced with
references to `unstable_act` in `react`. It is likely that the unstable
act implementation will be made stable. The test utils act is just a
reexport of the unstable_act implementation in react itself.
  • Loading branch information
gnoff authored Dec 6, 2023
1 parent aba93ac commit 9cae442
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions fixtures/dom/src/__tests__/nested-act-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('unmocked scheduler', () => {
beforeEach(() => {
jest.resetModules();
React = require('react');
DOMAct = require('react-dom/test-utils').act;
DOMAct = React.unstable_act;
TestRenderer = require('react-test-renderer');
TestAct = TestRenderer.act;
});
Expand Down Expand Up @@ -61,7 +61,7 @@ describe('mocked scheduler', () => {
require.requireActual('scheduler/unstable_mock')
);
React = require('react');
DOMAct = require('react-dom/test-utils').act;
DOMAct = React.unstable_act;
TestRenderer = require('react-test-renderer');
TestAct = TestRenderer.act;
});
Expand Down
4 changes: 2 additions & 2 deletions packages/react-devtools-shared/src/__tests__/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function act(
recursivelyFlush: boolean = true,
): void {
const {act: actTestRenderer} = require('react-test-renderer');
const {act: actDOM} = require('react-dom/test-utils');
const actDOM = require('react').unstable_act;

actDOM(() => {
actTestRenderer(() => {
Expand All @@ -44,7 +44,7 @@ export async function actAsync(
recursivelyFlush: boolean = true,
): Promise<void> {
const {act: actTestRenderer} = require('react-test-renderer');
const {act: actDOM} = require('react-dom/test-utils');
const actDOM = require('react').unstable_act;

await actDOM(async () => {
await actTestRenderer(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('ReactDOMServerHydration', () => {
React = require('react');
ReactDOMClient = require('react-dom/client');
ReactDOMServer = require('react-dom/server');
act = require('react-dom/test-utils').act;
act = React.unstable_act;

console.error = jest.fn();
container = document.createElement('div');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ beforeEach(() => {
yields = [];
React = require('react');
ReactDOM = require('react-dom');
act = require('react-dom/test-utils').act;
act = React.unstable_act;
container = document.createElement('div');
document.body.appendChild(container);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/react-refresh/src/__tests__/ReactFresh-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('ReactFresh', () => {
ReactDOM = require('react-dom');
ReactDOMClient = require('react-dom/client');
Scheduler = require('scheduler');
act = require('react-dom/test-utils').act;
act = React.unstable_act;
internalAct = require('internal-test-utils').act;

const InternalTestUtils = require('internal-test-utils');
Expand Down Expand Up @@ -3792,7 +3792,7 @@ describe('ReactFresh', () => {
React = require('react');
ReactDOM = require('react-dom');
Scheduler = require('scheduler');
act = require('react-dom/test-utils').act;
act = React.unstable_act;
internalAct = require('internal-test-utils').act;

// Important! Inject into the global hook *after* ReactDOM runs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('ReactFreshIntegration', () => {
ReactFreshRuntime = require('react-refresh/runtime');
ReactFreshRuntime.injectIntoGlobalHook(global);
ReactDOM = require('react-dom');
act = require('react-dom/test-utils').act;
act = React.unstable_act;
container = document.createElement('div');
document.body.appendChild(container);
exportsObj = undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('ReactFlightDOMForm', () => {
ReactServerDOMClient = require('react-server-dom-webpack/client.edge');
ReactDOMServer = require('react-dom/server.edge');
ReactDOMClient = require('react-dom/client');
act = require('react-dom/test-utils').act;
act = React.unstable_act;
useFormState = require('react-dom').useFormState;
container = document.createElement('div');
document.body.appendChild(container);
Expand Down

0 comments on commit 9cae442

Please sign in to comment.