fix: use Teleport with disabled=true instead of stub #2632
+103
−11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes #2628
cc @Alevagre7
As part of #1889 the child of Teleport is wrapped with an arrow function. This aligns with how Vue expects it (that's why we don't have the warning anymore). However the stub doesn't use the same implementation for the Teleport as Vue does: Vue doesn't render the children, but waits for the Teleport component to be mounted, then render the children in the teleport target element.
Instead of using a stub, we have a proposal to utilize the
disabled
prop from the Vue API for the Teleport component (https://vuejs.org/guide/built-ins/teleport#disabling-teleport) instead of creating a custom stub for it.By using the official API, we can rely on native functionality rather than introducing a stub, which can lead to more friction and increase the likelihood of errors. The
disabled
prop allows us to effectively "disable" the teleport behavior, which aligns with the intent behind stubbing—removing specific behavior from the unit test.In essence, whenever someone creates a stub for a component, the goal is typically to abstract away its behavior during testing. Using the
disabled
prop achieves the same outcome in a cleaner and more reliable manner.The implementation may not be the best, so @cexbrayat if you have suggestions for it we can change it.
Thanks!