开玩笑无法导入js文件

时间:2019-05-23 19:03:07

标签: unit-testing vue.js jestjs

尝试导入要在单元测试中使用的文件时,出现错误

  

Jest遇到意外令牌-这通常意味着您   正在尝试导入Jest无法解析的文件,例如不是   普通的JavaScript。

文件内容似乎无关紧要。

这是package.json


"devDependencies": {
   "@babel/core": "^7.4.4",
   "@babel/preset-env": "^7.4.4",
   "@nuxtjs/style-resources": "^0.1.2",
   "@vue/cli-plugin-eslint": "^3.7.0",
   "@vue/eslint-config-prettier": "^4.0.1",
   "babel-eslint": "^10.0.1",
   "eslint": "^5.16.0",
   "eslint-config-prettier": "^4.2.0",
   "eslint-friendly-formatter": "^4.0.1",
   "eslint-loader": "^2.1.2",
   "eslint-plugin-prettier": "^3.0.1",
   "eslint-plugin-vue": "^5.2.2",
   "jest-transform-stub": "^2.0.0",
   "node-sass": "^4.12.0",
   "nodemon": "^1.19.0",
   "prettier": "^1.17.0",
   "prettier-eslint-cli": "^4.7.1",
   "sass-loader": "^7.1.0",
   "wallaby-vue-compiler": "^1.0.5"
 },
 "babel": {
   "presets": [
     "@babel/preset-env"
   ]
 },
 "jest": {
   "moduleFileExtensions": [
     "js",
     "json",
     "vue"
   ],
   "transform": {
     "^.+.vue$": "vue-jest",
     "^.+.js$": "babel-jest",

     "^.+\\.js$": "<rootDir>/node_modules/babel-jest"
   },
   "moduleNameMapper": {
     "@/(.*)$": "<rootDir>/$1",
     "^vue$": "vue/dist/vue.common.js"
   }
 }
}

0 个答案:

没有答案