Skip to content

fix: render globally registered components stubbed with false when nested - #3042

Merged
cexbrayat merged 1 commit into
vuejs:mainfrom
ValentinYoushkevich:fix/stubs-false-global-components
Nov 23, 2026
Merged

cexbrayat merged 1 commit into
vuejs:mainfrom
ValentinYoushkevich:fix/stubs-false-global-components

Conversation

@ValentinYoushkevich

Copy link
Copy Markdown
Contributor

global.components + stubs: { X: false } only un-stubs X in the mounted component. In any child, X renders <!----> with "Component is missing template or render function", in mount and shallowMount, from mounting options or config.global.

const Child = { template: '<global-component/>' }
mount({ components: { Child }, template: '<Child />' }, {
  global: {
    components: { GlobalComponent },
    stubs: { GlobalComponent: false }
  }
})
// <!---->

This is the RouterLink: false toggle #504 was added for (vue-router-mock puts RouterLink in config.global.components and stubs it with true). It only works for a <router-link> in the root component.

#504 skipped registration when the stub value was truthy. #816, a types-only change, switched to key in global.stubs, so for false only the { name } placeholder gets registered. The root still works because global.components is merged into its local components. This goes back to checking the value.

A kebab-case key in stubs ('global-component': false) still resolves to the placeholder registered under that name; that is the separate placeholder loop, so I left it out of this PR.

Real-world workaround: https://github.com/Sacane/JManager/blob/4c538519ada78809aa509898a1a13be047c4e10a/client/components/NewPasswordFields.vue#L1-L5 (setup: https://github.com/Sacane/JManager/blob/4c538519ada78809aa509898a1a13be047c4e10a/client/tests/setup.ts#L218-L242)

Playground (2.6.0): https://play.vuejs.org/#eNp9U01v2zAM/SuEMEAy4MjBDhtgxFmHYthlp7Y7RQHqJGzsVpYEfTgdPP/3QXK9BFmxk02+58dH0hzIV2N4H5CUZOX2tjUeHPpg1kK1ndHWwwAWn3JocrDotOzxVndGK1QeRniyugPaB6QX/E6HC/CmD1h4dH4RfCsdFUqovVbOgw4eqqjOqA1KterIOafZDH+XelfLc7UqWVEHtCWwDKo1NIwe2p7mQCcuzWAUqihmpw5WVyJr2P0CVXeYg2xfEGrw2BlZe4RWQQ0KnccD7Gf+7OW2aeXhXQfXQ2H0qiTNkqtJ507r/zayaVgqlW3TR0I59A9thzp4NlEHoQAmsVNtlYMKNttzTp+gSq9aIo+EGZpjqIBxzusklhS4Ca5h99626sjqzXKbZRc1bG0MWqimrbLYQD6ZADimTss5hPPcXAnDPwsc85nnfNi9RynhqZYOY+uRlh5j9k4L+hSTOnje1zIgVPB49+3+548HaHwnqw/Dm28eQ5aN8Bs8vvpKkDMUEywbBQGGrwb3cfGCTI4EyeD3NJ4olsYkUR19A1+m9Ga55U62e2TLHD4vMyiBKq2Qjo9CRc+rYrqndVzjav7N1tH3ylhcD0M6gHFcFTGMH1yQSE6me1p0teHPTitSkjRn8QY4Qf5OXpCrK4uYII33xpVFEZR5OfK97oor2s1H/okvi0PrfNEHXJwRjq5b7Kw+ObT82QmSViHUSMY/O+1t+g==

@netlify

netlify Bot commented Nov 19, 2026

Copy link
Copy Markdown

👷 Deploy request for vue-test-utils-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 5206aa8

@pkg-pr-new

pkg-pr-new Bot commented Nov 19, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 5206aa8

@cexbrayat
cexbrayat merged commit a4f55fc into vuejs:main Nov 23, 2026
6 checks passed
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.

2 participants