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
I'm testing a page. And inside the unit test I'd like to access the setup state, so I can execute the onSuccess function.
It is possible but it seems a bit cumbersome, I understand I have to find the component because it's wrapped.
<template><div>Example</div></template><scriptsetuptype="ts">const{ data }=awaituseDetailData();functiononSuccess(){window.dispatchEvent(newCustomEvent('success'));</script>
This a unit test, as you can see it's difficult to access the setupState of the wrapped Componened passed to mountSuspended.
Or is this already possible somehow? Else I'd be able to make a PR to expose the setupState for easier access.
it('should dispatch success event',async()=>{constwrapper=awaitmountSuspended(DetailPage);// name of file is [...slug].vueconstspy=vi.spyOn(window,'dispatchEvent');// this worksconstdetailPageWrapper=wrapper.findComponent({name: '[...slug]'}).componentVM._.setupState;// But i'd prefer to use something like this instead: constdetailPageWrapper=wrapper.findComponent({name: '[...slug]'}).vm// Or thiswrapper.setupState.onSuccess();detailPageWrapper.onSuccess();expect(spy).toHaveBeenCalledWith(expect.objectContaining({type: 'success'}));});
The text was updated successfully, but these errors were encountered:
TimvdEijnden
changed the title
Easier access to setupState
[mountSuspended]Easier access to setupState
Nov 15, 2023
TimvdEijnden
changed the title
[mountSuspended]Easier access to setupState
[mountSuspended] Easier access to setupState
Nov 15, 2023
I'm testing a page. And inside the unit test I'd like to access the setup state, so I can execute the
onSuccess
function.It is possible but it seems a bit cumbersome, I understand I have to find the component because it's wrapped.
This a unit test, as you can see it's difficult to access the setupState of the wrapped Componened passed to mountSuspended.
Or is this already possible somehow? Else I'd be able to make a PR to expose the setupState for easier access.
The text was updated successfully, but these errors were encountered: