Add junit reporter to karma for Jenkins
authorFrank Bessou <frank.bessou@logilab.fr>
Wed, 29 Mar 2017 16:54:27 +0200
changeset 52 8cf6ce9a5e66
parent 51 f34d8c3f3156
child 53 c8d75f60411e
Add junit reporter to karma for Jenkins
.hgignore
Jenkinsfile
karma.conf.js
package.json
--- a/.hgignore	Wed Mar 29 17:17:40 2017 +0200
+++ b/.hgignore	Wed Mar 29 16:54:27 2017 +0200
@@ -1,4 +1,5 @@
 dist
+reports
 node_modules
 .eslintcache
 demo/server/cubicweb_bookstore.egg-info
--- a/Jenkinsfile	Wed Mar 29 17:17:40 2017 +0200
+++ b/Jenkinsfile	Wed Mar 29 16:54:27 2017 +0200
@@ -11,6 +11,7 @@
     }
 
     stage('Tests') {
-        sh 'npm run test:ci'
+        sh 'npm run test'
+        junit 'reports/karma.junit'
     }
 }
--- a/karma.conf.js	Wed Mar 29 17:17:40 2017 +0200
+++ b/karma.conf.js	Wed Mar 29 16:54:27 2017 +0200
@@ -37,7 +37,13 @@
     // test results reporter to use
     // possible values: 'dots', 'progress'
     // available reporters: https://npmjs.org/browse/keyword/karma-reporter
-    reporters: ['progress'],
+    reporters: ['progress', 'junit'],
+
+    junitReporter: {
+        outputDir: 'reports',
+        outputFile: 'karma.junit',
+        useBrowserName: false,
+    },
 
 
     // web server port
--- a/package.json	Wed Mar 29 17:17:40 2017 +0200
+++ b/package.json	Wed Mar 29 16:54:27 2017 +0200
@@ -30,6 +30,7 @@
     "jsonary": "0.0.16",
     "karma": "^1.5.0",
     "karma-firefox-launcher": "^1.0.1",
+    "karma-junit-reporter": "^1.2.0",
     "karma-mocha": "^1.3.0",
     "karma-phantomjs-launcher": "^1.0.4",
     "karma-webpack": "^2.0.3",
@@ -42,7 +43,6 @@
   },
   "scripts": {
     "test:watch": "karma start",
-    "test:ci": "karma start --single-run",
     "test": "karma start --single-run || true",
     "build": "webpack --progress --config development.config.js",
     "watch": "webpack --progress -d --watch",