Open
Description
Version
13.0.0
Reproduction link
https://github.com/riovir/injected-component-reprod
Steps to reproduce
Clone - install - test with the given repo, or:
- npm i -g vue-cli
- vue init webpack
- make sure to pick unit tests
- npm i
- npm i -D vue-loader@13.0.0
- open test/specs/Hello.spec.js and add these two snippets
it('should render correct contents even when injecting', () => {
const HelloInjector = require('!!vue-loader?inject!@/components/Hello')
const Constructor = Vue.extend(HelloInjector({}))
const vm = new Constructor().$mount()
expect(vm.$el.querySelector('.hello h1').textContent)
.to.equal('Welcome to Your Vue.js App')
})
- run the test to see they pass
- make a copy of Hello.vue (eg. Hello0.vue)
- rerunning the tests should trigger the error:
ERROR LOG: '[Vue warn]: Failed to mount component: template or render function not defined. (found in <Root>)'
- npm i -D vue-loader@12.2.1
- rerunning "fixes the tests"
What is expected?
Mock-injected components to behave the same way as their regularly loaded counterparts. Particularly where the render function is concerned.
What is actually happening?
In arbitrary situations (project size seems to be a factor) inject-loaded Vue components fail to mount due to missing render function.