-
Notifications
You must be signed in to change notification settings - Fork 266
Bug: Reactivity breaks when Teleport is stubbed in unit tests, causing unexpected unmounts on teleported components #2628
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
Comments
Hi @Alevagre7 If I run the tests, everything seems to work:
did you forget something? |
That’s correct, @cexbrayat. Apologies for the confusion. I discovered that adding await nextTick() allows the second test to pass, but it doesn’t actually resolve my issue. As you can see from the logs, during the second test execution, the Child component unmounts and mounts again. This behavior is inconsistent with how it works in the browser. Do you have any insights into what might be triggering this behavior? |
I don't know what triggers this behavior sorry, but as it is a stub, it's not really surprising that it does not behave like the real Teleport component. The built-in stubs are fairly basic (see
|
Hi @cexbrayat thanks for your response! I modified slightly the codesandbox that @Alevagre7 shared in the OP so it's more obvious the functionality is very different and it may make a lot components untestable without a major refactor. I understand that the stub is not intended to have the same functionality, so if you consider this as a known issue I understand it. However I think it's a pity that such a simple scenario is imposible to test with the stub. I'm debugging the library, and I'll try to provide a PR if I manage to fix it. |
Hi @victor141516 thank you for updating the repro I agree that this should work out of the box. If you find anything, I'll gladly review and merge the PR 👍 |
Describe the bug
Stubbing out Teleport in unit tests causes reactivity to behave unexpectedly. Specifically, the teleport component unmounts when its props are updated, but only when the Teleport is stubbed. This behavior differs from what is observed in the browser console, where the Child component stays mounted and reactivity works correctly.
To Reproduce
A minimal reproduction is available here: https://codesandbox.io/p/devbox/adoring-water-3pxr5p
Repro Steps
Expected behavior
Both unit tests should pass, with reactivity working regardless of whether Teleport is stubbed or pointing to a real target.
Observed behaviour
Only the non-stubbed teleport test is passing.
Related information:
System:
OS: Linux 6.1 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
CPU: (2) x64 AMD EPYC
Memory: 1.57 GB / 4.14 GB
Container: Yes
Shell: Unknown
npmPackages:
@vue/test-utils: 2.4.6 => 2.4.6
vitest: 3.0.8 => 3.0.8
vue: ^3.5.13 => 3.5.13
Additional context
Credits to @victor141516 for helping triaging this issue.
The text was updated successfully, but these errors were encountered: