diff --git a/packages/create-instance/patch-render.js b/packages/create-instance/patch-render.js index 4ab5dca47..43387d6a7 100644 --- a/packages/create-instance/patch-render.js +++ b/packages/create-instance/patch-render.js @@ -108,10 +108,9 @@ export function patchRender (_Vue, stubs, stubAllComponents) { const stub = createStubIfNeeded(stubAllComponents, original, _Vue, el) if (stub) { - vm.$options.components = { - ...vm.$options.components, + Object.assign(vm.$options.components, { [el]: stub - } + }) modifiedComponents.add(el) } } diff --git a/test/specs/shallow-mount.spec.js b/test/specs/shallow-mount.spec.js index d135f9308..7dd91b877 100644 --- a/test/specs/shallow-mount.spec.js +++ b/test/specs/shallow-mount.spec.js @@ -13,8 +13,8 @@ import { describeRunIf, itDoNotRunIf } from 'conditional-specs' describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => { beforeEach(() => { - sinon.stub(console, 'info') - sinon.stub(console, 'error') + sinon.stub(console, 'info').callThrough() + sinon.stub(console, 'error').callThrough() }) afterEach(() => { @@ -490,4 +490,30 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => { '' ) }) + + itDoNotRunIf( + vueVersion < 2.1, + 'does not error when rendering a previously stubbed component', () => { + const ChildComponent = { + render: h => h('div') + } + const TestComponent = { + template: ` +
+ + + + +
+ `, + components: { + ExtendedComponent: Vue.extend({ render: h => h('div') }), + ChildComponent + } + } + shallowMount(TestComponent) + mount(TestComponent) + expect(console.error) + .not.calledWith(sinon.match('Unknown custom element')) + }) })