From fb7a66c2910473023ddad261db6d842301ad4049 Mon Sep 17 00:00:00 2001 From: Edd Yerburgh Date: Sat, 1 Dec 2018 09:50:26 +0000 Subject: [PATCH] feat: do not stub unregistered components (#1048) --- packages/create-instance/patch-render.js | 5 ++++- test/specs/shallow-mount.spec.js | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/create-instance/patch-render.js b/packages/create-instance/patch-render.js index fb3b463d3..b06c72c80 100644 --- a/packages/create-instance/patch-render.js +++ b/packages/create-instance/patch-render.js @@ -87,8 +87,11 @@ export function patchRender (_Vue, stubs, stubAllComponents) { if (typeof el === 'string') { let original = resolveComponent(el, originalComponents) + if (!original) { + return originalCreateElement(el, ...args) + } + if ( - original && original.options && original.options.$_vueTestUtils_original ) { diff --git a/test/specs/shallow-mount.spec.js b/test/specs/shallow-mount.spec.js index d4c65cf47..97e29d0e6 100644 --- a/test/specs/shallow-mount.spec.js +++ b/test/specs/shallow-mount.spec.js @@ -9,7 +9,7 @@ import ComponentWithoutName from '~resources/components/component-without-name.v import ComponentAsAClassWithChild from '~resources/components/component-as-a-class-with-child.vue' import RecursiveComponent from '~resources/components/recursive-component.vue' import { vueVersion } from '~resources/utils' -import { describeRunIf, itDoNotRunIf, itSkipIf } from 'conditional-specs' +import { describeRunIf, itDoNotRunIf } from 'conditional-specs' describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => { beforeEach(() => { @@ -379,8 +379,17 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => { .to.equal('hey') }) - itSkipIf( - typeof Proxy === 'undefined', + it('does not stub unregistered components', () => { + const TestComponent = { + template: '' + } + const wrapper = shallowMount(TestComponent) + + expect(wrapper.html()) + .to.equal('') + }) + + it( 'stubs lazily registered components', () => { const Child = { render: h => h('p')