Some wrapped act userEvents produce "The current testing environment is not configured to support act" warnings
Asked Answered
S

0

6

I'm having trouble understanding the need of act and user events. I've read this issue and the linked blogpost but thats not exactly my case https://github.com/testing-library/user-event/issues/497 This does not yield any warning:

await act(async () => await user.keyboard("{Enter}"));

But this results in the warning below generated:

await act(async () => await user.hover(await screen.findByLabelText("connection-target")));

console.error
  Warning: The current testing environment is not configured to support act(...)

  at printWarning (node_modules/react-dom/cjs/react-dom.development.js:86:30)
  at error (node_modules/react-dom/cjs/react-dom.development.js:60:7)
  at isConcurrentActEnvironment (node_modules/react-dom/cjs/react-dom.development.js:25260:7)
  at warnIfUpdatesNotWrappedWithActDEV (node_modules/react-dom/cjs/react-dom.development.js:27559:12)
  at scheduleUpdateOnFiber (node_modules/react-dom/cjs/react-dom.development.js:25508:5)
  at Object.enqueueSetState (node_modules/react-dom/cjs/react-dom.development.js:14067:7)
  at List.setState (node_modules/react/cjs/react.development.js:354:16)
  at call (node_modules/react-window/src/createListComponent.js:646:12)
  at tick (node_modules/react-window/src/timer.js:26:16)
  at runAnimationFrameCallbacks (node_modules/jsdom/lib/jsdom/browser/Window.js:599:13)
  at Timeout.<anonymous> (node_modules/jsdom/lib/jsdom/browser/Window.js:577:11)

I can remove the act that produces the warning and the test stays green but I dont want to run into false positives due to my changes.

Seldom answered 31/3, 2023 at 11:25 Comment(1)
I am still looking for the answer, did you figure out, meanwhile ?Wedge

© 2022 - 2024 — McMap. All rights reserved.