Closed markabruce closed 2 years ago
You are using setTimeout
. Are you mocking the timer?
https://jestjs.io/docs/timer-mocks
Apologies, forgot to do that in the noddy project, but have done it in my own on the beforeEach
before creating the wrapper:
subscriptionTiersModuleActions.getSubscriptionTiers.mockResolvedValue(expectedSubscriptionTiers);
userSubscriptionModuleActions.getUserSubscription.mockResolvedValue(userSubscriptionTierOne);
I can update the noddy project and make sure though - will have to be after work.
Ok, had some time, got it to run:
beforeEach(async () => {
jest.useFakeTimers();
const ChildAsyncSetupComponentWrappedInSuspense = defineComponent({
components: { ChildAsyncSetupComponent },
template: '<Suspense><ChildAsyncSetupComponent/></Suspense>'
})
wrapper = mount(ChildAsyncSetupComponentWrappedInSuspense);
jest.runAllTimers();
await flushPromises();
await nextTick();
});
Snapshot:
+ <!-- eslint-disable max-len -->
+ <div>This is the Async Setup Component</div>
+ <!-- eslint-enable max-len -->
Closing this, there must be something I've not configured correctly with my mocks.
Thanks for the help and apologies for raising this unnecessarily!
Just to note, it was because my project was on test utils v2.0.0-rc18 - I've upgraded it to v2.0.0
Describe the bug When a component uses
async setup
and it's parent component wraps it in a suspense, when running a.html
snapshot test, the HMTL snapshot remains empty.To Reproduce Here is a little noddy project I created to reproduce this issue: https://github.com/markabruce/Vue3SuspenseAsyncSetupHTMLSnapshotIssue
Steps:
async setup
and include some awaiting function call in setupasync setup
in a Suspense within the parent componentExpected behavior
wrapper.html()
should return the HTML of the component.Related information:
Vue
version: 3.2.13node
version: v17.2.0npm
(oryarn
) version: 8.1.4Additional context None, thanks in advance.