所以我能够让我的业力报道得以运行。
------------------|----------|----------|----------|----------|----------------|
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
------------------|----------|----------|----------|----------|----------------|
src/ | 91.49 | 62.5 | 93.33 | 97.56 | |
app.js | 91.67 | 50 | 100 | 100 | |
child-router.js | 91.67 | 50 | 100 | 100 | |
users.js | 91.3 | 75 | 85.71 | 95.24 | 24 |
------------------|----------|----------|----------|----------|----------------|
All files | 91.49 | 62.5 | 93.33 | 97.56 | |
------------------|----------|----------|----------|----------|----------------|
问题是我在src/
文件夹中有其他文件似乎没有检测到。例如,我添加了一个src/test.js
,但未被覆盖范围接收。我不确定为什么覆盖范围只占据/src
内部的一部分文件。
这是我的Karma.Config:
/*eslint-disable no-var*/
var webpackConfig = require('./webpack.config.js');
webpackConfig.entry = {};
// Karma configuration
// Generated on Fri Feb 26 2016 14:25:47 GMT+0100 (CET)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'build/bundle.js',
'test/unit/**/*.spec.js'
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
//'build/bundle.js': ['webpack'], // why is this here??
'test/**/*.js': ['webpack'],
'src/**/*.js': ['webpack']
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress', 'coverage'],
coverageReporter: {
dir: 'build/coverage',
reporters: [
{ type: 'html', subdir: 'report-html' },
{ type: 'text'}
]
},
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity,
webpack: {
module: {
loaders: [{ test: /\.js$/, loader: 'babel', exclude: /node_modules/, query: { presets: ['es2015-loose', 'stage-1'], plugins: ['transform-decorators-legacy'] } }],
postLoaders: [{
test: /\.js$/, exclude: /(node_modules|test)/,
loader: 'istanbul-instrumenter'
}]
}
},
webpackMiddleware: {
noInfo: true
}
});
};