Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions packages/shared/stub-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
19 changes: 18 additions & 1 deletion test/specs/shallow-mount.spec.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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({
Expand Down