You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constx=renderHook(()=>useMyCustomHook());returnx.waitForValueToChange(()=>x.result).then(()=>{// do nothing});
What happened:
MyCustomHook
Warning: This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning.
1) myfirsttest
0 passing (1s)
1 failing
1) MyCustomHook
myfirsttest:
ReferenceError: MessageChannel is not defined
at enqueueTaskImpl (webpack:///./node_modules/react-test-renderer/cjs/react-test-renderer.development.js?:14656:23)
at enqueueTask (webpack:///./node_modules/react-test-renderer/cjs/react-test-renderer.development.js?:14663:10)
at flushWorkAndMicroTasks (webpack:///./node_modules/react-test-renderer/cjs/react-test-renderer.development.js?:14893:5)
at eval (webpack:///./node_modules/react-test-renderer/cjs/react-test-renderer.development.js?:14974:11)
andrewagain
changed the title
ReferenceError: MessageChannel is not defined
waitForValueToChange: ReferenceError MessageChannel is not defined
Jul 7, 2021
Can you provide some more details on how you are running the tests. I can see webpack so presumably you are bundling. Are you running the tests in a browser or still in node?
Another things to try is using the @testing-library/react-hooks/dom import. I've found some of the "fixes" in react only work in react-dom and react-test-renderer gets forgotten/ignored.
react-hooks-testing-library
version: Tried 6.0.0 and 7.0.1react
version: Tried 16.12.0, 16.14.0, and 17.0.1react-dom
version (if applicable): Always kept the same as react versionreact-test-renderer
version (if applicable): Always kept the same as react versionnode
version: v14.15.5npm
(oryarn
) version: yarn 1.22.10Relevant code or config:
Also tried:
What happened:
Research:
Looks like a similar issue in React has a workaround here: facebook/react#20756 (comment)
I tried that workaround and it didn't help. Also that workaround looks like it is for Node 15 and I am on Node 14.
The problem only seems to happen if I use
await
.The text was updated successfully, but these errors were encountered: