diff --git a/src/utils/componentName.ts b/src/utils/componentName.ts
index 77535f0a3..b00cc98ed 100644
--- a/src/utils/componentName.ts
+++ b/src/utils/componentName.ts
@@ -28,6 +28,14 @@ export const getComponentRegisteredName = (
}
}
+ // try to infer the name based on global resolution
+ const globalRegistry = instance.appContext.components
+ for (const key in globalRegistry) {
+ if (globalRegistry[key] === type) {
+ return key
+ }
+ }
+
// try to retrieve name imported in script setup
return getComponentNameInSetup(instance.parent, type) || null
}
diff --git a/tests/mountingOptions/global.stubs.spec.ts b/tests/mountingOptions/global.stubs.spec.ts
index cf9b57a5d..cad7780e5 100644
--- a/tests/mountingOptions/global.stubs.spec.ts
+++ b/tests/mountingOptions/global.stubs.spec.ts
@@ -367,6 +367,36 @@ describe('mounting options: stubs', () => {
expect(wrapper.html()).toBe('