Skip to content

fix: stub globally registered components by alias#2895

Open
ifer47 wants to merge 1 commit into
vuejs:mainfrom
ifer47:fix/stub-global-registration-name
Open

fix: stub globally registered components by alias#2895
ifer47 wants to merge 1 commit into
vuejs:mainfrom
ifer47:fix/stub-global-registration-name

Conversation

@ifer47

@ifer47 ifer47 commented Jun 29, 2026

Copy link
Copy Markdown

Summary

  • resolve component registration names from the app-level component registry when matching global.stubs
  • keep local component registration names as the first priority, then fall back to global registrations and existing script setup/name inference
  • add a regression test for components registered by a plugin under a public alias that differs from the component's internal name

Root Cause

getComponentRegisteredName() only inspected the parent component's local components option. Components installed through plugins or libraries with app.component('GlobalAlias', Component) were resolved by Vue at runtime, but Vue Test Utils could only see the component's internal name. As a result, global.stubs.GlobalAlias did not match unless the internal component name happened to be the same.

Fixes #2541.

Validation

  • pnpm test tests/mountingOptions/global.stubs.spec.ts -t "globally registered component by its registration name" --run
  • pnpm test tests/mountingOptions/global.stubs.spec.ts --run
  • pnpm test tests/mountingOptions/global.components.spec.ts --run
  • pnpm test --run
  • pnpm run lint
  • pnpm run vue-tsc
  • pnpm exec oxfmt --check src/utils/componentName.ts tests/mountingOptions/global.stubs.spec.ts

@netlify

netlify Bot commented Jun 29, 2026

Copy link
Copy Markdown

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

Name Link
🔨 Latest commit 4a27c45
🔍 Latest deploy log https://app.netlify.com/projects/vue-test-utils-docs/deploys/6a428837cd724300081d2dc3
😎 Deploy Preview https://deploy-preview-2895--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.

@ifer47 ifer47 marked this pull request as ready for review June 29, 2026 15:00
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.

Bug: stubs does not respect globally registered component names

1 participant