【发布时间】:2021-06-30 02:58:07
【问题描述】:
这是我的代码。有人可以帮我找出错误吗。我正在使用 jest 来测试我使用 Vue 构建的前端。行 const localVue = createLocalVue();给出错误 TypeError: (0 , _testUtils.createLocalVue) is not a function
import { createLocalVue,shallowMount } from '@vue/test-utils'
import Vuex from 'vuex'
import getters from '../../src/store/module/auth/getters.js'
import TheHeader from '@/components/layout/TheHeader.vue'
// const store = new Vuex.Store({
// state: {
// user:null,
// token:'',
// expiresIn:null,
// isUserLoggedIn:false,
// isAdminLoggedIn:false,
// }
// })
describe('TheHeader', () => {
const localVue = createLocalVue();
localVue.use(Vuex);
let store
let state
it('Checks whether the login is correctly displayed', () => {
const cmp = shallowMount(TheHeader, { store,localVue})
expect(cmp.name()).toMatch('TheHeader')
expect(cmp.vm.isLoggedIn()).toBe(false)
})
})
【问题讨论】:
标签: vue.js unit-testing jestjs