早上好,
我有一个似乎无法解决的奇怪问题。我写出了我的 Karma 测试并正确执行,但是当我尝试连接 Karma 的代码覆盖率时,无论如何它只会 100% 吐出。
我查看了这里提出的其他问题,但似乎都没有解决我的问题。任何帮助将不胜感激。
使用:
"karma": "~0.12.37",
"karma-babel-preprocessor": "^5.2.1",
"karma-browserify": "^4.2.1",
"karma-coverage": "^0.4.2",
"karma-jasmine": "~0.3.5",
"karma-phantomjs-launcher": "^0.2.0",
这是我的 karma.conf.js
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['browserify', 'jasmine'],
files: [
'bower_components/jquery/dist/jquery.js',
'bower_components/angular/angular.js',
'bower_components/angular-animate/angular-animate.js',
'bower_components/angular-cookies/angular-cookies.js',
'bower_components/angular-mocks/angular-mocks.js',
'bower_components/angular-resource/angular-resource.js',
'bower_components/angular-sanitize/angular-sanitize.js',
'bower_components/angular-touch/angular-touch.js',
'bower_components/angular-ui-router/release/angular-ui-router.js'
'src/*.html',
'src/**/*.html',
'src/app/index.js',
'src/app/**/*.js'
],
exclude: [],
preprocessors: {
'src/app/index.js': ['browserify', 'coverage'],
'src/app/**/*.js': ['browserify', 'coverage']
},
browserify: {
debug: true,
transform: ['babelify', 'stringify']
},
reporters: ['progress', 'coverage'],
port: 9876,
colors: true,
autoWatch: true,
browsers: ['PhantomJS'],
singleRun: false
});
};
我的文件结构是:
src
app
login
login.controller.js
login.controller.spec.js
login.html
index.js
karma.conf.js
谢谢!