Javascript 业力覆盖文件路径
我有一个文件夹结构的项目,如 项目Javascript 业力覆盖文件路径,javascript,karma-runner,Javascript,Karma Runner,我有一个文件夹结构的项目,如 项目 |--网络 |----脚本 |------应用程序 |--------feature.js |------Libs |------测试 |--------规格 |----------规格js |--------karma-conf.js 在我的karma-conf.js中,我将覆盖率预处理器指向。/App/feature.js,但这会给我一个空白的覆盖率报告,说明“没有要显示的数据” 我尝试了一些其他路径配置,但没有成功。业力文档说明路径应该是相对于基本路径的
|--网络
|----脚本
|------应用程序
|--------feature.js
|------Libs
|------测试
|--------规格
|----------规格js
|--------karma-conf.js 在我的karma-conf.js中,我将覆盖率预处理器指向。/App/feature.js,但这会给我一个空白的覆盖率报告,说明“没有要显示的数据” 我尝试了一些其他路径配置,但没有成功。业力文档说明路径应该是相对于基本路径的。由于遗留原因,我无法移动测试文件夹 下面是我的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'
// 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
})
}我在因果报应中的路径也遇到了一些问题。。。是否尝试将
base/
附加到路径。这对我来说很管用,谢谢你的回复。出于类似的原因,我目前正努力让咕噜嘎玛(grunt karma)发挥作用。我认为是时候重构文件夹结构了。