我正在使用 vue test utils 进行简单的单元测试。但它不起作用。我不知道....帮帮我
我安装了这些东西.....
> $ npm i -D jest @vue/test-utils vue-jest jest-serializer-vue babel-jest babel-core@bridge
> $ npm i -D @babel/core @babel/preset-env
Run Code Online (Sandbox Code Playgroud)
我做了jest.config.js文件
module.exports = {
moduleFileExtensions: [
'vue',
'js'
],
moduleNameMapper: {
'^~/(.*)$': '<rootDir>/src/$1'
},
modulePathIgnorePatterns: [
'<rootDir>/node_modules',
'<rootDir>/dist'
],
testURL: 'http://localhost',
transform: {
'^.+\\.vue$' : 'vue-jest',
'^.+\\.jsx?$' : 'babel-jest'
}
}
Run Code Online (Sandbox Code Playgroud)
和测试/Parent.test.js
import { mount } from '@vue/test-utils'
import Parent from './Parent.vue'
test('Mount', () => {
const wrapper = mount(Parent)
expect(wrapper.html()).toBe('')
})
Run Code Online (Sandbox Code Playgroud)
但是 npm …