视频
官方文档https://www.jestjs.cn/docs/getting-started
报错:
Cannot use import statement outside a module:
原因:jest不支持babel版本7问题:(网上很多文章解决不了)
1.用git上的方法先。
https://github.com/facebook/jest/search?q=babel-core&type=code
2..babelrc文件的配置注释掉
VUE-jest配置
用 Jest 测试单文件组件
安装成功,跳第七步
import { mount } from '@vue/test-utils'
import Component from './component'
describe('Component', () => {
test('is a Vue instance', () => {
const wrapper = mount(Component)
expect(wrapper.isVueInstance()).toBeTruthy()
})
})