I have a project with a folder structure like
Project
|--Web
|----Scripts
|------App
|--------feature.js
|------Libs
|------Tests
|--------Specs
|----------spec.js
|--------karma-conf.js
In my karma-conf.js I'm point the coverage preprocessor to ../App/feature.js but this gives me a blank coverage report stating 'No data to display'.
I've tried some other path configurations with no luck. Karma documentation states that the path should be relative to the base path. I can't move the test folder for legacy reasons.
Below is a duplicate of my karma-conf.js
I'd be very grateful for any insight into how the paths work for karma-coverage.
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"
}
});
};
base/to the path. It worked for me from inside the specs - Sergio