JestでVuetifyのcomponentsが読み込めないconsole.errorが表示される話
JestでVuetifyのcomponentsのerrorが出る
適当なテスト用のコードを書いて見るとテストはPASSするけどconsole.errorが吐かれる
console.error {path}
[Vue warn]: Unknown custom element: <v-card> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
解決: localVue.use(vuetify)
localVue.use(vuetify)
を書き忘れていただけだったようです。
test/pages/index.spec.js
import Vuetify from 'vuetify'
import { mount, createLocalVue } from '@vue/test-utils'
import IndexPage from '@/pages/index.vue'
const localVue = createLocalVue()
describe('pages/index.vue', () => {
let vuetify
let wrapper
beforeEach(() => {
vuetify = new Vuetify()
// これを追加
localVue.use(vuetify)
wrapper = mount(IndexPage, {
localVue
})
})
describe('template', () => {
it('「Hellow World」の表示', () => {
expect(wrapper.text()).toBe('Hellow World')
})
})
})
Author And Source
この問題について(JestでVuetifyのcomponentsが読み込めないconsole.errorが表示される話), 我々は、より多くの情報をここで見つけました https://qiita.com/HorikawaTokiya/items/06578fb50bb181751ed6著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .