-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error clicking element inside React Flow node in jest test with @testing-library #2461
Comments
For what it's worth / in case anyone else has found the same issue, I've realised I can work around the issue by creating a test version of the button inside a Portal. |
I think the error comes from d3-drag, which doesn't support being run in a non-browser environment (similar issue here: d3/d3-drag#79). We are using d3-drag to drag the nodes and the error is produced because d3-drag monitors the mousedown event. To disable d3-drag in your test, you have two options:
I have tested both options in the repository you provided and the test was run successfully. Let me know if this works for you. |
Thank you. I used |
Upstream issue and PR raised |
sry to resurrect a dead thread, but I'm seeing the same reported error arise again on the latest version of reactflow when using this is even with I think I've tracked it down this time to coming from the d3-zoom library (which calls back to d3-drag under the hood), which is being initiated no matter what in the that's about as far as I got without digging into the internals of d3-zoom, but wondering if anyone here has also run into that? |
Yeah, I get the error when testing in Storybook with Surely people are writing tests for At any rate, you can't write Storybook tests involving clicking, since they fail on this unhandled exception. |
@matttk thanks for the update here. We will check again if there is a way to solve this. |
Also facing this issue (and have done exactly as @matttk!). Upgrading / downgrading the reactflow version doesn't seem to help either |
Describe the Bug
I have a jest test that renders a component using React Flow and then clicks an element inside one of the nodes. I receive this exception:
Your Example Website or App
https://github.com/amagee-willow/react-flow-test-click
Steps to Reproduce the Bug or Issue
Expected behavior
The click should be successful and there should be no error
Screenshots or Videos
No response
Platform
Additional context
No response
The text was updated successfully, but these errors were encountered: