【发布时间】:2018-08-05 02:50:43
【问题描述】:
我正在为使用 axios 的组件编写测试。 我得到了:
TypeError: Cannot read property 'get' of undefined
之后
yarn test。
我试图将 axios 导入到我的 *spec.js 文件中,但它不起作用。
我应该怎么做才能通过这些测试?
【问题讨论】:
-
import VueAxios from 'vue-axios' import axios from 'axios' import { mount } from '@vue/test-utils' import Component from '../src/components/courses/Courses' describe('Component', () => { test('is a Vue instance', () => { const wrapper = mount(Component) expect(wrapper.isVueInstance()).toBeTruthy() }) }) -
请用代码更新你的问题。
标签: javascript testing vue.js axios jestjs