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
2. By reading another part of the documentation I understood I overrode the Transition stub, so it was considered as a regular Stub due to shallowMount behavior. I added it back to the stub object, as PascalCase as the documentation refers to:
It stubs Transition and TransitionGroup by default.
The snapshot is now working and showing the slot content
<transition-stubname="fade" appear="false" persisted="false" css="true"><my-component-stub></my-component-stub><p>hello from MyOtherComponent</p></transition-stub>
Solution
It seems createStubComponentsTransformer is testing both kebab-case and PascalCase for some Vue built-in components (keep-alive / KeepAlive) but not for others transition, transition-group, teleport which are only tested against the kebab-case version.
So the solution would be to apply the same logic as KeepAlive.
Side note
I've solved my issue in a more elegant way by extending the default global stubs object.
@lbineau Yeah I remember fixing it for KeepAlive when someone opened an issue
Would you like to try and open a PR for the others? That would be a great help. You can do as I did in f69bc37
Issue
Here is a sample of my testing code as per the documentation https://test-utils.vuejs.org/api/#global-stubs (please pay attention to the PascalCase / kebab-case notations)
Given this simplified Vue component (
v-if="true"
to simplify the logic)1. Following the documentation I put all global stubs in PascalCase:
It produces the following result: the Transition
slot
content is removed while it should not.2. By reading another part of the documentation I understood I overrode the
Transition
stub, so it was considered as a regular Stub due toshallowMount
behavior. I added it back to the stub object, as PascalCase as the documentation refers to:But the snapshot was still showing the same (no
slot
content)3. After reading the source code I found out that the default stubs are in kebab-case:
So I needed to convert the transition component to kebab-case
The snapshot is now working and showing the
slot
contentSolution
It seems
createStubComponentsTransformer
is testing both kebab-case and PascalCase for some Vue built-in components (keep-alive
/KeepAlive
) but not for otherstransition
,transition-group
,teleport
which are only tested against the kebab-case version.So the solution would be to apply the same logic as
KeepAlive
.Side note
I've solved my issue in a more elegant way by extending the default global stubs object.
The text was updated successfully, but these errors were encountered: