Skip to content

fix: only apply stubs to the app being rendered - #2997

Open
ValentinYoushkevich wants to merge 1 commit into
vuejs:mainfrom
ValentinYoushkevich:fix/stubs-per-app
Open

ValentinYoushkevich wants to merge 1 commit into
vuejs:mainfrom
ValentinYoushkevich:fix/stubs-per-app

Conversation

@ValentinYoushkevich

Copy link
Copy Markdown
Contributor

mount, shallowMount and renderToString install their stubs with Vue's global transformVNodeArgs and never remove them, so any other app rendered later in the same file still gets stubbed, even after unmount():

shallowMount(Loading).unmount()

const el = document.createElement('div')
createApp({ render: () => h(Loading) }).mount(el)
el.innerHTML // '<b-loading-stub></b-loading-stub>'

The same happens with createSSRApp + @vue/server-renderer (<transition-stub> in the server HTML, hydration mismatch), and a wrapper mounted earlier re-renders with the stubs of the last mounted one. Repro: playground (2.5.1), playground (main)

The transformer of each app is now stored in a WeakMap keyed by the app, and a single dispatcher installed with transformVNodeArgs applies the one of the app being rendered (vnodes created outside of any component still use the last mounted wrapper's transformer). Since every transformer now only sees its own app, the mountedRootComponents set from #2890 is no longer needed and is removed (the #2675 test still passes). Note that components rendered by another app, e.g. one created with createApp inside a component, are no longer stubbed.

Projects working around this in their tests:

@netlify

netlify Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for vue-test-utils-docs ready!

Name Link
🔨 Latest commit cbd56a9
🔍 Latest deploy log https://app.netlify.com/projects/vue-test-utils-docs/deploys/6ae579914d747edcd7f54f5b
😎 Deploy Preview https://deploy-preview-2997--vue-test-utils-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new

pkg-pr-new Bot commented Oct 31, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@vue/test-utils@2997

commit: cbd56a9

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant