feat(test-utils): allow mounting single component for testing#5723
feat(test-utils): allow mounting single component for testing#5723
Conversation
✅ Deploy Preview for nuxt3-docs canceled.
|
|
💡 Ideas from @danielroe
|
|
Introducing the side-effects of app.vue is probably not the best idea. It makes implementation more fragile and less consistant with selective-ssr components. |
|
If we are on hold for App.vue side-effects, I think the first MVP is ready for review/discussion and then we can iterate in future PRs. |
|
I'm waiting for a review on this PR for #5689 standardizing universal isolated component rendering API.
Sure. I think generally it is a bad decision but if we want to try can be done in another future PR. |
247e18b to
c98e5c7
Compare
|
LGTM, thanks! |
|
With nuxt-vitest, this is probably no longer needed? |
|
Providing a way to render a single component using the nuxt pipeline is also helpful in other scenarios like storybook or cypress integration, see eg nuxt/nuxt#18596 and cypress-io/cypress#23619. |
danielroe
left a comment
There was a problem hiding this comment.
I've moved this to a subpath - @nuxt/test-utils/experimental that will either allow us to iterate more quickly on the remaining TODO items, or possibly take an alternative path (if @antfu prefers) akin to the work on https://github.com/danielroe/nuxt-vitest.
Thank you so much for your work on this.
🔗 Linked issue
❓ Type of change
📚 Description
This PR enables a special route
/__nuxt_component_test__/to mount a single component from everywhere while preserving the Nuxt's pipeline and context. Also added$fetchComponentandcomponentTestUrlutil to@nuxt/test-utilsto construct the URL easier.Caveat
Since it uses dynamic imports from strings, it will only work on dev mode with Vite +
viteNode: true📝 Checklist