shallowMountをmountに変更でエラー(Vue Test Utils)
MochaとChaiでVue unit testを書いています。
shallowMountだと上手くいくのに、mountを使うとエラーになってしまう箇所があります。
なぜでしょうか。
画像格納先のパスがおかしいのかと思うのですが、どう直せば良いのでしょうか。
テスト:
import ComponentModal from '@/components/ComponentModal.vue'
const wrapper = mount(ComponentModal) //ここでエラー
エラー:
Error: Cannot find module './.jpg'
at webpackContextResolve (dist/webpack:/src/assets/images sync ^\.\/.*\.jpg$:221:1)
at webpackContext (dist/webpack:/src/assets/images sync ^\.\/.*\.jpg$:215:1)
at Proxy.render (dist/webpack:/src/components/Modal.vue?5c14:12:1)
at VueComponent.Vue._render (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:3517:1)
at VueComponent.updateComponent (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:4019:1)
at Watcher.get (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:4419:1)
at new Watcher (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:4408:1)
at mountComponent (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:4026:1)
at VueComponent../node_modules/vue/dist/vue.runtime.esm.js.Vue.$mount (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:8350:1)
at init (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:3093:1)
at createComponent (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:5918:1)
at createElm (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:5865:1)
at createChildren (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:5993:1)
at createElm (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:5894:1)
at createChildren (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:5993:1)
at createElm (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:5894:1)
at createChildren (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:5993:1)
at createElm (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:5894:1)
at VueComponent.patch [as __patch__] (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:6417:1)
at VueComponent.Vue._update (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:3898:1)
at VueComponent.updateComponent (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:4019:1)
at Watcher.get (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:4419:1)
at new Watcher (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:4408:1)
at mountComponent (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:4026:1)
at VueComponent../node_modules/vue/dist/vue.runtime.esm.js.Vue.$mount (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:8350:1)
at init (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:3093:1)
at createComponent (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:5918:1)
at createElm (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:5865:1)
at VueComponent.patch [as __patch__] (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:6417:1)
at VueComponent.Vue._update (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:3898:1)
at VueComponent.updateComponent (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:4019:1)
at Watcher.get (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:4419:1)
at new Watcher (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:4408:1)
at mountComponent (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:4026:1)
at VueComponent../node_modules/vue/dist/vue.runtime.esm.js.Vue.$mount (dist/webpack:/node_modules/vue/dist/vue.runtime.esm.js:8350:1)
at mount (dist/webpack:/node_modules/@vue/test-utils/dist/vue-test-utils.js:8649:1)
at Context.it (dist/webpack:/tests/unit/components/ComponentModal.spec.js:62:1)