-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to latest main - wdyt @antfu?
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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$fetchComponent
andcomponentTestUrl
util to@nuxt/test-utils
to construct the URL easier.Caveat
Since it uses dynamic imports from strings, it will only work on dev mode with Vite +
viteNode: true
π Checklist