/how-vue-test

Vue project multi test methods, includes unit, snapshoot and e2e

Primary LanguageJavaScript

Vue 项目中的常用测试方法和模式,包括单元测试、快照测试和端到端测试

安装

yarn add jest vue-jest babel-jest babel-core@bridge @vue/test-utils -D

配置

package.json 增加 jest 配置, 或者在根目录新建 jest.config.js 配置文件

"jest": {
  "transform": {
    "^.+\\.js$": "babel-jest",
    "^.+\\.vue$": "vue-jest"
  },
  "testEnvironment": "jsdom"
}

修改 eslint 配置

"env": {
  "jest": true  
}

测试方法