From 5cf59306d42ab3cc89219266d9635f36c9b7e5ee Mon Sep 17 00:00:00 2001 From: Lenz Weber-Tronic Date: Mon, 2 Dec 2024 16:08:46 +0100 Subject: [PATCH] `actAsync` for React 17 --- src/testing/internal/rtl/actAsync.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/testing/internal/rtl/actAsync.ts b/src/testing/internal/rtl/actAsync.ts index 70a64009643..134c1a32053 100644 --- a/src/testing/internal/rtl/actAsync.ts +++ b/src/testing/internal/rtl/actAsync.ts @@ -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(scope: () => T | Promise): Promise { - return React.act(async () => { + return reactAct(async () => { return await scope(); }); }