Vue 3: Async component with suspense wrapper
See original GitHub issueStruggling to test a async component. I created a suspense wrapper component with defineComponent
which i think should work but it doesn’t:
it("renders a async component with a suspense wrapper", () => {
const Component = defineComponent({
async setup() {
return () => h("div", "AsyncSetup");
},
});
const { getByText } = render(
defineComponent({
render() {
return h(Suspense, null, {
default: h(Component),
fallback: h("div", "fallback"),
});
},
})
);
expect(getByText("AsyncSetup")).toBeInTheDocument(); // fails
});
Also created a repository for reproducing the issue.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:7
- Comments:8 (7 by maintainers)
Top Results From Across the Web
Suspense | Vue.js
<Suspense> is a built-in component for orchestrating async dependencies in a component tree. It can render a loading state while waiting for multiple...
Read more >The Complete Guide to Suspense in Vue3 - CODE Magazine
The wrapped component makes use of the async setup() function and awaits an async/promise operation to fetch data from a back-end server. The ......
Read more >Vue Suspense — Everything You Need to Know
Suspense is a built-in Vue.js 3 component, that simplifies coordinating loading states even, in deeply nested components.
Read more >Improve User Experience in Vue 3 with Suspense
"Suspense" is a new built-in component in Vue that we can wrap around another component needing to perform an asynchronous action before it ......
Read more >Async with Suspense - Vue Mastery
With Vue 3, we received a new and quite special component called <Suspense /> . In a nutshell, it allows us to better...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any updates on this? We have embraced Suspense and async components very heavily in our project and this is really holding us back in writing tests. I’ve noticed it’s the last part of making this library fully Vue 3 compatible.
As workaround i’m using a modified version of therender
function calledrenderAsync
for now. The code can be viewed here.After many problems with JSDOM/HappyDOM and issues like this i decided not to use VTL anymore. Playwright component testing has a almost identical API, is fast as well and runs in a real browser…