From 3c61f74486adcc79adb1fc2c366ecdb3ddaef3cb Mon Sep 17 00:00:00 2001
From: Susanne Moog <susanne.moog@typo3.com>
Date: Wed, 22 Jun 2016 12:35:40 +0200
Subject: [PATCH] [TASK] Add karma-coverage and karma-junit-reporter

To get junit compatible results and code coverage
reports that can be understood by CI systems this
patch adds dependencies to karma-coverage and
karma-junit-reporter. It also adds the necessary configuration.

Change-Id: I27ae2e7e6aecf3271d21c1ccff9f8458092cc5e5
Releases: master
Resolves: #76730
Reviewed-on: https://review.typo3.org/48634
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
Reviewed-by: Helmut Hummel <typo3@helhum.io>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 Build/package.json                              |  2 ++
 .../Build/Configuration/JSUnit/karma.conf.js    | 17 +++++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/Build/package.json b/Build/package.json
index d3c12edf4952..6c2b678a8c09 100644
--- a/Build/package.json
+++ b/Build/package.json
@@ -22,9 +22,11 @@
     "jasmine-core": "^2.4.1",
     "karma": "^0.13.22",
     "karma-chrome-launcher": "^1.0.1",
+    "karma-coverage": "^1.0.0",
     "karma-firefox-launcher": "^1.0.0",
     "karma-ie-launcher": "^1.0.0",
     "karma-jasmine": "^1.0.2",
+    "karma-junit-reporter": "^1.0.0",
     "karma-opera-launcher": "^1.0.0",
     "karma-phantomjs-launcher": "^1.0.0",
     "karma-requirejs": "^1.0.0",
diff --git a/typo3/sysext/core/Build/Configuration/JSUnit/karma.conf.js b/typo3/sysext/core/Build/Configuration/JSUnit/karma.conf.js
index 173b24082cfc..a88894fe03fd 100644
--- a/typo3/sysext/core/Build/Configuration/JSUnit/karma.conf.js
+++ b/typo3/sysext/core/Build/Configuration/JSUnit/karma.conf.js
@@ -29,12 +29,25 @@ module.exports = function(config) {
 		// preprocess matching files before serving them to the browser
 		// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
 		preprocessors: {
+			'typo3/sysext/**/Resources/Public/JavaScript/**/*.js': ['coverage']
 		},
 
 		// test results reporter to use
-		// possible values: 'dots', 'progress'
+		// possible values: 'dots', 'progress', 'coverage', 'junit'
 		// available reporters: https://npmjs.org/browse/keyword/karma-reporter
-		reporters: ['progress'],
+		reporters: ['progress', 'junit', 'coverage'],
+
+		junitReporter: {
+			outputDir: 'typo3temp/var/tests/',
+			useBrowserName: false,
+			outputFile: 'karma.junit.xml'
+		},
+
+		coverageReporter: {
+			reporters: [
+				{type: 'clover', dir: 'typo3temp', subdir: 'var/tests', file: 'karma.clover.xml'}
+			]
+		},
 
 		// web server port
 		port: 9876,
-- 
GitLab