Karma unit reporter not recognized
I am trying to run tests and generate reports using karma. I installed karma-junit-reporter, but I keep getting the following messages on the command line:
Cannot find plugin "karma-junit-reporter"
Can not load "junit", it is not registered
My karma.config.js:
plugins : [
'karma-jasmine',
'karma-junit-reporter',
'karma-phantomjs-launcher'
]
My package.json:
"devDependencies": {
"grunt": "0.4.5",
"grunt-cli": "0.1.13",
"grunt-env": "0.4.2",
"grunt-exec": "0.4.6",
"grunt-jasmine-node": "0.2.1",
"grunt-jasmine-node-coverage": "0.1.10",
"grunt-jscs": "1.8.0",
"grunt-karma": "0.11.2",
"jasmine-core": "2.3.4",
"jasmine-node": "1.14.3",
"jasmine-reporters": "0.4.1",
"jscs": "1.13.1",
"jshint": "2.4.4",
"karma": "0.12.37",
"karma-jasmine": "0.3.6",
"karma-junit-reporter": "0.2.2",
"karma-phantomjs-launcher": "0.2.0",
"phantomjs": "1.9.17",
"supertest": "0.9.0"
}
+3
source to share
1 answer
Making sure you are running npm install
and that all your plugin dependencies are in your package. json, as @ssube says in the title, is a good place to start. That being said, here's what worked for me:
module.exports = function (config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
browsers: ["PhantomJS"],
frameworks: ["jasmine-jquery" ,"jasmine"],
files: [
{
pattern: "test/**/*.html",
included: false,
served: true,
watched: true
},
"dist/latest/phone.min.js",
"node_modules/jquery/dist/jquery.js"
{
pattern: "test/functional/test/phoneTest.js",
watched: true
}
], plugins: [
"karma-jasmine-jquery",
"karma-phantomjs-launcher",
"karma-junit-reporter",
"karma-jasmine"
],
client: {
"captureConsole": true
},
phantomjsLauncher: {
// Have phantomjs exit if a ResourceError is encountered (useful if karma exits without killing phantom)
exitOnResourceError: true
},
singleRun: true,
reporters: ['progress', 'junit'],
junitReporter: {
outputDir: "testResults",
outputFile: "FUNCTIONAL-TEST-results.xml"
}
});
};
+2
source to share