VUE单元测试:vue-jest-unit-test
【腾讯云】亏本大甩卖,服务器4核16G 1年370元(带宽12M,系统盘120GB SSD盘,月流量2000GB)!!!!!!
云产品 配置 价格
服务器 1核2G,带宽5M,系统盘50GB SSD盘,月流量500GB 38元/年
MySQL 1核1G 19元/年
服务器 16核32G,带宽18M,系统盘250GB SSD盘,月流量5000GB 1197元/年
点我进入腾讯云,查看更多详情

package.json配置:

 

{
  "name": "longfor",
  "version": "1.0.0",
  "description": "A Vue.js project",
  "author": "",
  "private": true,
  "scripts": {
    "dev": "node build/dev-server.js",
    "start": "node build/dev-server.js",
    "build": "node build/build.js",
    "prod": "node build/online.js",
    "preonline": "node build/preonline.js",
    "uat": "node build/uat.js",
    "dll": "webpack -p --progress --config build/webpack.dll.conf.js",
    "unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run",
    "e2e": "node test/e2e/runner.js",
    "test": "jest",
    "lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
  },
  "dependencies": {
    "ali-oss": "^6.1.1",
    "axios": "^0.16.2",
    "babel-polyfill": "^6.26.0",
    "better-scroll": "^1.15.2",
    "clipboard": "^2.0.4",
    "echarts": "^4.2.1",
    "echarts-gl": "^1.1.1",
    "element-ui": "^1.4.13",
    "html2canvas": "^1.0.0-rc.3",
    "immutable": "^3.8.2",
    "lodash": "^4.17.11",
    "moment": "^2.24.0",
    "vconsole": "^3.3.0",
    "vee-validate": "^2.0.0-rc.21",
    "vue": "^2.6.10",
    "vue-awesome-swiper": "^3.1.3",
    "vue-bus": "^1.1.0",
    "vue-jsonp": "^0.1.7",
    "vue-qart": "^2.2.0",
    "vue-qr": "^2.1.0",
    "vue-quill-editor": "^3.0.6",
    "vue-router": "^2.7.0",
    "vuedraggable": "^2.23.0",
    "vuex": "^3.0.1",
    "wangeditor": "^3.0.15"
  },
  "devDependencies": {
    "@vue/test-utils": "^1.0.0-beta.29",
    "assets-webpack-plugin": "^3.5.1",
    "autoprefixer": "^7.1.2",
    "babel-eslint": "^7.1.1",
    "babel-jest": "^22.4.3",
    "babel-core": "^6.26.3",
    "babel-loader": "^7.1.1",
    "babel-plugin-istanbul": "^4.1.1",
    "babel-plugin-transform-runtime": "^6.22.0",
    "babel-preset-env": "^1.3.2",
    "babel-preset-stage-2": "^6.22.0",
    "babel-register": "^6.22.0",
    "chai": "^3.5.0",
    "chalk": "^2.0.1",
    "chromedriver": "^2.35.0",
    "clean-webpack-plugin": "^0.1.17",
    "compression-webpack-plugin": "^1.0.1",
    "connect-history-api-fallback": "^1.3.0",
    "copy-webpack-plugin": "^4.0.1",
    "cross-env": "^5.0.1",
    "cross-spawn": "^5.0.1",
    "css-loader": "^0.28.0",
    "cssnano": "^3.10.0",
    "eslint": "^4.19.1",
    "eslint-config-standard": "^6.2.1",
    "eslint-friendly-formatter": "^3.0.0",
    "eslint-loader": "^1.7.1",
    "eslint-plugin-html": "^3.0.0",
    "eslint-plugin-promise": "^3.4.0",
    "eslint-plugin-standard": "^2.0.1",
    "eventsource-polyfill": "^0.9.6",
    "express": "^4.14.1",
    "extract-text-webpack-plugin": "^3.0.2",
    "file-loader": "^0.11.1",
    "friendly-errors-webpack-plugin": "^1.1.3",
    "happypack": "^5.0.0",
    "html-webpack-inject-jscss-plugin": "0.0.1",
    "html-webpack-plugin": "^2.28.0",
    "http-proxy-middleware": "^0.17.3",
    "image-webpack-loader": "^4.2.0",
    "inject-loader": "^3.0.0",
    "jest": "^24.9.0",
    "karma": "^1.4.1",
    "karma-coverage": "^1.1.1",
    "karma-mocha": "^1.3.0",
    "karma-phantomjs-launcher": "^1.0.2",
    "karma-phantomjs-shim": "^1.4.0",
    "karma-sinon-chai": "^1.3.1",
    "karma-sourcemap-loader": "^0.3.7",
    "karma-spec-reporter": "0.0.31",
    "karma-webpack": "^2.0.2",
    "less": "^2.7.3",
    "less-loader": "^4.0.5",
    "mocha": "^3.2.0",
    "nightwatch": "^0.9.12",
    "opn": "^5.1.0",
    "optimize-css-assets-webpack-plugin": "^2.0.0",
    "ora": "^1.2.0",
    "phantomjs-prebuilt": "^2.1.14",
    "rimraf": "^2.6.0",
    "selenium-server": "^3.0.1",
    "semver": "^5.3.0",
    "shelljs": "^0.7.6",
    "sinon": "^2.1.0",
    "sinon-chai": "^2.8.0",
    "style-loader": "^0.19.1",
    "uglifyjs-webpack-plugin": "^1.0.0-rc.0",
    "url-loader": "^0.5.8",
    "vconsole": "^3.3.4",
    "vue-jest": "^3.0.5",
    "vue-loader": "^13.7.1",
    "vue-style-loader": "^3.0.1",
    "vue-template-compiler": "^2.4.2",
    "webpack": "^3.10.0",
    "webpack-bundle-analyzer": "^2.2.1",
    "webpack-dev-middleware": "^1.10.0",
    "webpack-hot-middleware": "^2.18.0",
    "webpack-merge": "^4.1.0",
    "webpack-parallel-uglify-plugin": "^1.1.0",
    "webpack-sftp-client": "^1.2.1"
  },
  "engines": {
    "node": ">= 4.0.0",
    "npm": ">= 3.0.0"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8"
  ],
  "jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "vue"
    ],
    "transform": {
      ".*.(vue)$": "vue-jest",
      "^.+.js$": "<rootDir>/node_modules/babel-jest"
    },
    "moduleNameMapper": {
      "^@/(.*)$": "<rootDir>/src/$1"
    },
    "collectCoverage": true,
    "testURL": "http://localhost/",
    "collectCoverageFrom": [
      "src/**/*.{js,vue}",
      "!**/node_modules/**"
    ],
    "coverageReporters": [
      "html",
      "text"
    ],
    "coverageDirectory": "<rootDir>/test/unit/coverage"
  }
}

  摸索了两天,终于配置出了一套能用的,按照以上执行cnpm/npm install,然后npm test即可

推荐文章

ubuntu 14.04 安装vim YouCompleteMe自动补全插件 Linux C/C++高手必备

ubuntu 14.04 安装vim YouCompleteMe自动补全插件 Linux C/C++高手必备

推荐文章

win7的svn客户端查看日志时,出现:there has been a problem contacting the server

win7的svn客户端查看日志时,出现:there has been a problem contacting the server

推荐文章

SVN配置

SVN配置

推荐文章

学习总结20160726

学习总结20160726

推荐文章

Linux下修改jar、zip等文件内的文件

Linux下修改jar、zip等文件内的文件

推荐文章

Mac 终端里 vim 的常用用法

Mac 终端里 vim 的常用用法

推荐文章

linux下使用yum安装svn

linux下使用yum安装svn

推荐文章

Linux vim使用和iconv乱码解决

Linux vim使用和iconv乱码解决

推荐文章

iOS 【network-SVN 命令行操作】

iOS 【network-SVN 命令行操作】

推荐文章

推荐vim 一键配置

推荐vim 一键配置

推荐文章

耗时整整一天,整理出的超详细清晰的vim,vimrc配置

耗时整整一天,整理出的超详细清晰的vim,vimrc配置

推荐文章

iOS 【network-CornerStone托管配置SVN】

iOS 【network-CornerStone托管配置SVN】

推荐文章

Linux 初学实战之环境配置

Linux 初学实战之环境配置

推荐文章

svn出现黄色感叹号怎么办

svn出现黄色感叹号怎么办

推荐文章

Vim常用的总结

Vim常用的总结

推荐文章

vim如何查找vimfiles

vim如何查找vimfiles