Open Lenny-Hu opened 4 years ago
https://github.com/vuejs/vue-cli/issues/1363#issuecomment-521692197
[1/3] Install babel-plugin-istanbul + configure it in babel.config.js
npm install --save-dev babel-plugin-istanbul
// babel.config.js module.exports = { presets: [ '@vue/app' ], env: { test: { plugins: [ ['istanbul', { useInlineSourceMaps: false }] ] } } };
[2/3]: Install nyc + configure it in nyc.config.js
npm install nyc --save-dev
// nyc.config.js module.exports = { 'check-coverage': false, 'per-file': true, 'skip-full': true, all: true, include: [ 'src/**/*.{js,vue}' ], exclude: [ 'src/*.js', '**/index.js' ], reporter: [ 'lcov', 'text', 'text-summary' ], extension: [ '.js', '.vue' ] };
[3/3] Use it
nyc vue-cli-service test:unit --require tests/setup.js
vue-lic3 mocha-webpack 生成覆盖率 (@vue/cli-plugin-unit-mocha)
https://github.com/vuejs/vue-cli/issues/1363#issuecomment-521692197
[1/3] Install babel-plugin-istanbul + configure it in babel.config.js
[2/3]: Install nyc + configure it in nyc.config.js
[3/3] Use it