diff --git a/packages/shared/stub-components.js b/packages/shared/stub-components.js index c56412de6..8fe7d3339 100644 --- a/packages/shared/stub-components.js +++ b/packages/shared/stub-components.js @@ -246,14 +246,13 @@ export function createComponentStubsForGlobals ( instance: Component ): Components { const components = {} - Object.keys(instance.options.components).forEach(c => { + for (const c in instance.options.components) { if (isRequiredComponent(c)) { - return + continue } - components[c] = createBlankStub(instance.options.components[c], c) delete instance.options.components[c]._Ctor delete components[c]._Ctor - }) + } return components } diff --git a/test/specs/shallow-mount.spec.js b/test/specs/shallow-mount.spec.js index 970230cef..21481c993 100644 --- a/test/specs/shallow-mount.spec.js +++ b/test/specs/shallow-mount.spec.js @@ -1,6 +1,6 @@ import { compileToFunctions } from 'vue-template-compiler' import Vue from 'vue' -import { mount, shallowMount } from '~vue/test-utils' +import { mount, shallowMount, createLocalVue } from '~vue/test-utils' import Component from '~resources/components/component.vue' import ComponentWithChild from '~resources/components/component-with-child.vue' import ComponentWithNestedChildren from '~resources/components/component-with-nested-children.vue' @@ -256,6 +256,23 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => { .to.equal('hey') }) + it('stubs components registered on localVue after multiple installs', () => { + const myPlugin = function (_Vue, opts) { + _Vue.mixin({ }) + } + const localVue = createLocalVue() + localVue.component('registered-component', { + render: h => h('time') + }) + const TestComponent = { + render: h => h('registered-component') + } + + localVue.use(myPlugin) + const wrapper = shallowMount(TestComponent, { localVue }) + expect(wrapper.html()).to.contain('registered-component-stub') + }) + it('throws an error when the component fails to mount', () => { expect(() => shallowMount({