我正在尝试检测我的代码以获得一些覆盖和运行,但是有些东西在我的手指上滑落.
我发布伊斯坦布尔:
node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha -- -u exports -R spec
我的mocha.opts看起来像这样:
app/assets/javascripts/components/**/*-mocha.jsx --compilers jsx:mocha/compiler.js
一切似乎运行良好(测试运行,至少),但我得到的唯一覆盖是用于编译JSX到JavaScript的文件(在compiler.js中使用)
compiler.js 100% jsx-stub-transform.js 65%
非常有用……
有任何想法吗?
我用
gulp-jsx-coverage.
这是我的配置示例:
var jsxCoverage = require('gulp-jsx-coverage'); gulp.task('test',['lint','env:test'],jsxCoverage.createTask({ src: ['src/**/*_test.js','src/**/*_test.jsx'],// will pass to gulp.src as mocha tests istanbul: { // will pass to istanbul coverageVariable: '__MY_TEST_COVERAGE__',exclude: /node_modules|tests|._test/ // do not instrument these files },transpile: { // this is default whitelist/blacklist for transpilers babel: { include: /\.jsx?$/,exclude: /node_modules/ } },coverage: { reporters: ['text','lcov','cobertura'],// list of istanbul reporters directory: 'coverage' // will pass to istanbul reporters },mocha: { // will pass to mocha reporter: 'spec' },babel: { // will pass to babel sourceMap: 'inline',// get hints in HTML coverage reports plugins: [] } }));
*更新*
随着时间的推移,我决定停止使用gulp-jsx-coverage.我的测试使用babel-rewire-plugin
,而gulp-jsx-coverage没有正确检测我的文件,导致报告中包含一堆未经测试的生成代码.没有bueno.
See my 2nd answer为我目前的设置.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。