????????????????????karma.conf.js
module.exports = function(config) {
config.set({
basePath: ''??
frameworks: ['jasmine']??
files: [
'test/**/*.js'
]??
exclude: []??
preprocessors: {
'test/**/*.js': ['webpack'?? 'coverage']
}??
reporters: ['progress'?? 'coverage']??
coverageReporter: {
type: 'html'??
dir: 'coverage/'
}??
port: 9876??
colors: true??
logLevel: config.LOG_INFO??
autoWatch: true??
browsers: ['PhantomJS']??
singleRun: false??
concurrency: Infinity??
webpack: {
module: {
loaders: [{
test: /.js$/??
loader: 'babel'??
exclude: /node_modules/??
query: {
presets: ['es2015']
}
}]
}
}
})
}
????????????????
????files?????test????????webpack??????????????????????????????????????????????????
????preprocessors?????test???????????webpack??????
????????webpack???????????????????????????????entry??output?????????babel-loader??????ES6????
???????? karma start ???????~
?????????Coverage???????????????????????????
???????????webpack??????Щ?????????????Coverage????????????????Щ???????????jquery??????????????????????????????????????????????Coverage?????ο???????
?????????д?????????????????????????????
????npm i --save-dev babel-plugin-istanbul
???????webpack??babel-loader??????
????{
????test: /.js$/??
????loader: 'babel'??
????exclude: /node_modules/??
????query: {
????presets: ['es2015']??
????plugins: ['istanbul']
????}
????}
?????????????????istanbul????????Coverage?????????preprocessors??? coverage ????
????????????? karma start ??????????~???OK?????????д????????~