Skip to content

Commit

Permalink
actAsync for React 17
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Dec 2, 2024
1 parent c9d918a commit 5cf5930
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/testing/internal/rtl/actAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
// and https://github.com/testing-library/react-testing-library/pull/1365

import * as React from "react";
import * as DeprecatedReactTestUtils from "react-dom/test-utils";

const reactAct =
typeof React.act === "function" ? React.act : DeprecatedReactTestUtils.act;

export function actAsync<T>(scope: () => T | Promise<T>): Promise<T> {
return React.act(async () => {
return reactAct(async () => {
return await scope();
});
}

0 comments on commit 5cf5930

Please sign in to comment.