vue-loader: Can't do multiple injects on the same file
When writing tests and I would like to change what is injected into a Vue file per test, but I get an error like Object is not a constructor (evaluating '__vue_exports__(injections)').
I’m doing something like
import SendInjector from '!!vue?inject!src/views/Send'
describe('Send', () => {
let test = (store) => {
let Send = SendInjector({ store })
}
})
If I call test once then it works as expected, but it throws an error on the second call.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 9
- Comments: 16 (5 by maintainers)
@LinusBorg Here’s a bare-bones repo built with vue-cli that is failing.
https://github.com/adam-hanna/vue-loader-inject-test
Ok i hope this works for you, otherwise just tell me so I can work on an isolated example. These would be the steps:
You can check Welcome.spec.js to check the tests. If you comment one of the two describes, tests will will work as expected. It only happens when trying to create another instance of the injected component.
Thanks in advance for the help !