依赖的版本很重要,不要出错了
devDependencies:{
"babel-core": "^6.26.3",
"babel-jest": "^22.4.3",
"babel-loader": "^7.1.1",
"babel-plugin-dynamic-import-webpack": "^1.1.0",
"jest": "^24.9.0",
"jest-serializer-vue": "^0.3.0",
"jest-transform-stub": "^2.0.0",
"vue-jest": "^3.0.5",
"vue-loader": "^13.7.1",
},
moduleFileExtensions: [
'js',
'jsx',
'json',
'vue'
],
globals: {
},
transform: {
'.*\\.(vue)$': 'vue-jest',
'.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
'^.+\\.js$': '<rootDir>/node_modules/babel-jest'
},
transformIgnorePatterns: [
'/node_modules/'
],
moduleNameMapper: {
'\\.(css|styl|less|sass|scss|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/__mocks__/fileMock.js',
'^@/(.*)$': '<rootDir>/src/$1'
},
snapshotSerializers: [
'jest-serializer-vue'
],
testMatch: [
'**/test/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)'
],
testURL: 'http://localhost/',
collectCoverage: true,
collectCoverageFrom: [
'src/page/**/*.{js,vue}'
],
coverageDirectory: '<rootDir>/test/unit/coverage'