diff --git a/packages/shared/stub-components.js b/packages/shared/stub-components.js index 3cc1ba207..6bc9250d3 100644 --- a/packages/shared/stub-components.js +++ b/packages/shared/stub-components.js @@ -202,6 +202,11 @@ function stubComponents ( const componentOptions = typeof cmp === 'function' ? cmp.extendOptions : cmp + + if (!componentOptions) { + stubbedComponents[component] = createBlankStub({}, component) + return + } // Remove cached constructor delete componentOptions._Ctor if (!componentOptions.name) { diff --git a/test/specs/mount.spec.js b/test/specs/mount.spec.js index ea9e79016..7b9a9e4f7 100644 --- a/test/specs/mount.spec.js +++ b/test/specs/mount.spec.js @@ -184,6 +184,22 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => { expect(wrapper.html()).to.equal(`
`) }) + itDoNotRunIf( + vueVersion < 2.4, // auto resolve of default export added in 2.4 + 'handles components as dynamic imports', (done) => { + const TestComponent = { + template: '
', + components: { + AsyncComponent: () => import('~resources/components/component.vue') + } + } + const wrapper = mount(TestComponent) + setTimeout(() => { + expect(wrapper.find(Component).exists()).to.equal(true) + done() + }) + }) + it('logs if component is extended', () => { const msg = `[vue-test-utils]: an extended child component ` + diff --git a/test/specs/shallow-mount.spec.js b/test/specs/shallow-mount.spec.js index 3b486bc27..4467fcb8c 100644 --- a/test/specs/shallow-mount.spec.js +++ b/test/specs/shallow-mount.spec.js @@ -294,6 +294,19 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => { .to.equal('hey') }) + itDoNotRunIf( + vueVersion < 2.4, // auto resolve of default export added in 2.4 + 'handles component as dynamic import', () => { + const TestComponent = { + template: '
', + components: { + AsyncComponent: () => import('~resources/components/component.vue') + } + } + const wrapper = shallowMount(TestComponent) + expect(wrapper.find({ name: 'AsyncComponent' }).exists()).to.equal(true) + }) + it('stubs components registered on localVue after multiple installs', () => { const myPlugin = function (_Vue, opts) { _Vue.mixin({ })