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
However, in our case it is probably not working because we have to use act() to fireEvent based on https://reactjs.org/docs/test-utils.html#act otherwise, we are getting warning. However, it is just my assumptions.
I will be grateful to hear any feedback or see the fixed version🙂
Thanks a lot in advance.
The text was updated successfully, but these errors were encountered:
Hey! Thank you for your bug report!
Much appreciated! 🙏
This is a bit unfortunate and a limitation of jsdom. Right now the transition related events don't fire properly and therefore the afterEnter and afterLeave callbacks are never called.
The workaround in Headless UI is not clean at all, it basically bails on those native events and uses a setTimeout that is cancellable.
Ideally you run this as integration tests in a real browser using Playwright or similar tools. We also have to do that but we didn't get to it yet (hence why a bunch of tests are skipped).
What package within Headless UI are you using?
@headlessui/react
What version of that package are you using?
v1.7.11
What browser are you using?
Node JS enviroment (tests)
Reproduction URL
Here is the minimal reproduction: https://codesandbox.io/s/transition-component-failing-mp8q7v?file=/src/Transition.test.tsx
Describe your issue
afterEnter
andafterLeave
are not being fired in React Transition component when we are testing our component in jest.It is a bit frustrating because we cannot test our functions in the components, which are being called when
afterEnter
orafterLeave
is fired. Therefore, we had to upgrade our@headlessui/react
to theversion 1.6.2
since it is working in this version. However, it seems that starting from theversion 1.6.3
it stopped to work (based on changelog: https://github.com/tailwindlabs/headlessui/blob/main/packages/@headlessui-react/CHANGELOG.md#163---2022-05-25)It seems like #1500 this PR could be reason.
Note: We found that you are also using
jest
andtesting-library
and in your case it is working. https://github.com/tailwindlabs/headlessui/blob/main/packages/%40headlessui-react/src/components/transitions/transition.test.tsx#L1356However, in our case it is probably not working because we have to use
act()
tofireEvent
based on https://reactjs.org/docs/test-utils.html#act otherwise, we are getting warning. However, it is just my assumptions.I will be grateful to hear any feedback or see the fixed version🙂
Thanks a lot in advance.
The text was updated successfully, but these errors were encountered: