dom*_*kun 6 code-coverage istanbul reactjs react-jsx
我正在尝试检测我的代码以获得一些覆盖和运行,但是有些东西在我的手指上滑落.
我推出istanbul:
node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha -- -u exports -R spec
Run Code Online (Sandbox Code Playgroud)
我mocha.opts看起来像这样:
app/assets/javascripts/components/**/*-mocha.jsx
--compilers jsx:mocha/compiler.js
Run Code Online (Sandbox Code Playgroud)
一切似乎运行良好(测试运行,至少),但我得到的唯一报道是用于编译JSX到JavaScript的文件(用于 compiler.js
compiler.js 100%
jsx-stub-transform.js 65%
Run Code Online (Sandbox Code Playgroud)
非常有用......
有任何想法吗?
这是我的配置示例:
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: []
}
}));
Run Code Online (Sandbox Code Playgroud)
随着时间的推移,我决定停止使用gulp-jsx-coverage. 我的测试使用babel-rewire-plugin,并且gulp-jsx-coverage没有正确地检测我的文件,导致覆盖率报告包含一堆未经测试的生成代码。没有布埃诺。
请参阅我当前设置的第二个答案。
| 归档时间: |
|
| 查看次数: |
1579 次 |
| 最近记录: |