[英]Karma-coverage file paths
我有一個文件夾結構類似的項目
項目
| --Web
| ----腳本
| ------應用
| -------- feature.js
| ------利布斯
| ------測試
| --------規格
| ---------- spec.js
| --------卡瑪 - conf.js
在我的karma-conf.js中,我將覆蓋率預處理器指向../App/feature.js,但這給了我一個空白的覆蓋率報告,指出“無數據可顯示”。
我嘗試了其他一些沒有運氣的路徑配置。 Karma文檔指出該路徑應相對於基本路徑。 由於遺留原因,我無法移動測試文件夾。
以下是我的karma-conf.js的副本
我非常感謝您對因果報酬路徑如何運作的任何見解。
module.exports = function (config) {
config.set({
hostname: 'localhost',
// base path, that will be used to resolve files and exclude
basePath: '',
// frameworks to use
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
{
pattern: '../App/feature.js',
watched: true,
served: true,
included: true
},
{
pattern: 'Specs/spec/*.js',
watched: true,
served: true,
included: true
}
],
// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['progress','coverage'],
// web server port
port: 6789,
// 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_DEBUG,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: true,
preprocessors: {
'**/.html': [],
'**/*.coffee': [],
"../App/feature.js": "coverage"
}
});
};
使用以下過程:
karma.conf.js
文件直接移動到Scripts
目錄下 App
處於同一級別,以便基本路徑匹配 將映射更改為:
'App/feature.js': 'coverage'
使用此鏈接作為參考: https : //jaredtong.com/2016/01/08/how-to-set-up-mocha-chai-sinon-karma-browserify-istanbul-codecov/
我知道要使用此配置:
// Karma configuration
// Generated on Tue Apr 25 2017 13:33:19 GMT-0400 (Eastern Daylight Time)
// Required by Browserify
var istanbul = require('browserify-istanbul');
module.exports = function(config) {
'use strict';
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
// Include Browserify first. https://www.npmjs.com/package/karma-browserify
frameworks: [ 'browserify', 'jasmine'],
// list of files / patterns to load in the browser
files: [
'src/**/*.js',
'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: {
'src/**/*.js': ['browserify'],
'spec/**/*.js': ['browserify']
},
browserify: {
debug: true,
transform: [
'brfs',
istanbul({
ignore: ['**/node_modules/**']
})
]
},
//
plugins: ['karma-chrome-launcher', 'karma-jasmine', 'karma-coverage', 'karma-firefox-launcher', 'karma-browserify'],
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['coverage'],
// optionally, configure the reporter
coverageReporter: {
type : 'html',
dir : 'coverage/',
includeAllSources: true
},
// 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
})}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.