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
Is your feature request related to a problem? Please describe.
I'm starting to add unit tests to a new Vue 3 project with Composition API and I have a lot of problems with the wrapper.vm not showing up my list of methods. After couple of hours of googling and searching through issues in this project, I thought that doing something like await (wrapper.vm as InstanceType<typeof LoginPage>).login() (and I found out that the vm is actually that same type anyway) would help me out but it turns out that it only started to work after exposing the method through defineExpose({ login });, ok great but the thing is that I don't want to revisit and expose these methods simply for the sake of unit testing and typing, I mean sure I could do something like (wrapper.vm as any).login() and I'm good to go but then I lose the typing benefit.
Describe the solution you'd like
I wish that there would be simpler ways of pulling my list of methods without exposing them (with defineExpose) in Composition API
Describe alternatives you've considered
Well I guess that I have 3 ways that I have found so far for dealing with this
simply cast the wrapper vm to any... (wrapper.vm as any).login()
expose all my methods through defineExpose... defineExpose({ login });
in most case I guess that I would go with the easiest which is step 1 but it's really sad to see that I completely lose the benefit of TypeScript typing.
Additional context
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
I'm starting to add unit tests to a new Vue 3 project with Composition API and I have a lot of problems with the
wrapper.vm
not showing up my list of methods. After couple of hours of googling and searching through issues in this project, I thought that doing something likeawait (wrapper.vm as InstanceType<typeof LoginPage>).login()
(and I found out that thevm
is actually that same type anyway) would help me out but it turns out that it only started to work after exposing the method throughdefineExpose({ login });
, ok great but the thing is that I don't want to revisit and expose these methods simply for the sake of unit testing and typing, I mean sure I could do something like(wrapper.vm as any).login()
and I'm good to go but then I lose the typing benefit.Some similar or related issues found
Describe the solution you'd like
I wish that there would be simpler ways of pulling my list of methods without exposing them (with
defineExpose
) in Composition APIDescribe alternatives you've considered
Well I guess that I have 3 ways that I have found so far for dealing with this
any
...(wrapper.vm as any).login()
defineExpose
...defineExpose({ login });
VueWrapper
like Bug: Plugins do not extends the VueWrapper type when mounting the wrapper with Typescript #1336 but I haven't tried that and I would find that it's way too much workin most case I guess that I would go with the easiest which is step 1 but it's really sad to see that I completely lose the benefit of TypeScript typing.
Additional context
The text was updated successfully, but these errors were encountered: