summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWinnie Hellmann <winnie@gitlab.com>2018-09-11 21:03:05 +0000
committerMike Greiling <mike@pixelcog.com>2018-09-11 21:03:05 +0000
commit01b669640ab02a9f3eb45d74396b27e1a4fa165d (patch)
tree56c10cb571b49754972f584a80189b6c6696a9e2
parent9b0764938315dd581cf38d8589f6811dc63b26a8 (diff)
downloadgitlab-ce-01b669640ab02a9f3eb45d74396b27e1a4fa165d.tar.gz
Generate JUnit report for Karma tests
-rw-r--r--.gitignore1
-rw-r--r--.gitlab-ci.yml2
-rw-r--r--config/karma.config.js15
-rw-r--r--package.json1
-rw-r--r--spec/javascripts/gfm_auto_complete_spec.js2
-rw-r--r--spec/javascripts/test_bundle.js5
-rw-r--r--yarn.lock11
7 files changed, 31 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index eb0875a977f..82b3d08f7a8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -78,3 +78,4 @@ eslint-report.html
/.gitlab_pages_secret
package-lock.json
/junit_rspec.xml
+/junit_karma.xml
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c0b622f5abd..cc27ac3677b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -743,6 +743,8 @@ karma:
paths:
- chrome_debug.log
- coverage-javascript/
+ reports:
+ junit: junit_karma.xml
code_quality:
<<: *dedicated-no-docs-no-db-pull-cache-job
diff --git a/config/karma.config.js b/config/karma.config.js
index 84810332dc2..c890c670619 100644
--- a/config/karma.config.js
+++ b/config/karma.config.js
@@ -80,11 +80,12 @@ if (specFilters.length) {
module.exports = function(config) {
process.env.TZ = 'Etc/UTC';
- const progressReporter = process.env.CI ? 'mocha' : 'progress';
-
const karmaConfig = {
basePath: ROOT_PATH,
browsers: ['ChromeHeadlessCustom'],
+ client: {
+ isCI: !!process.env.CI
+ },
customLaunchers: {
ChromeHeadlessCustom: {
base: 'ChromeHeadless',
@@ -104,11 +105,19 @@ module.exports = function(config) {
preprocessors: {
'spec/javascripts/**/*.js': ['webpack', 'sourcemap'],
},
- reporters: [progressReporter],
+ reporters: ['progress'],
webpack: webpackConfig,
webpackMiddleware: { stats: 'errors-only' },
};
+ if (process.env.CI) {
+ karmaConfig.reporters = ['mocha', 'junit'];
+ karmaConfig.junitReporter = {
+ outputFile: 'junit_karma.xml',
+ useBrowserName: false,
+ };
+ }
+
if (process.env.BABEL_ENV === 'coverage' || process.env.NODE_ENV === 'coverage') {
karmaConfig.reporters.push('coverage-istanbul');
karmaConfig.coverageIstanbulReporter = {
diff --git a/package.json b/package.json
index 1d69a9feb33..6dd6a84f1e0 100644
--- a/package.json
+++ b/package.json
@@ -137,6 +137,7 @@
"karma-chrome-launcher": "^2.2.0",
"karma-coverage-istanbul-reporter": "^1.4.2",
"karma-jasmine": "^1.1.2",
+ "karma-junit-reporter": "^1.2.0",
"karma-mocha-reporter": "^2.2.5",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^4.0.0-beta.0",
diff --git a/spec/javascripts/gfm_auto_complete_spec.js b/spec/javascripts/gfm_auto_complete_spec.js
index 1cb20a1e7ff..4f9cacf2724 100644
--- a/spec/javascripts/gfm_auto_complete_spec.js
+++ b/spec/javascripts/gfm_auto_complete_spec.js
@@ -146,7 +146,7 @@ describe('GfmAutoComplete', function () {
shouldNotBeFollowedBy.forEach((followedSymbol) => {
const seq = atSign + followedSymbol;
- it(`should not match "${seq}"`, () => {
+ it(`should not match ${JSON.stringify(seq)}`, () => {
expect(defaultMatcher(atwhoInstance, atSign, seq)).toBe(null);
});
});
diff --git a/spec/javascripts/test_bundle.js b/spec/javascripts/test_bundle.js
index 4452c470b82..b89d10cb993 100644
--- a/spec/javascripts/test_bundle.js
+++ b/spec/javascripts/test_bundle.js
@@ -1,6 +1,7 @@
/* eslint-disable
jasmine/no-global-setup, jasmine/no-unsafe-spy, no-underscore-dangle, no-console
*/
+/* global __karma__ */
import $ from 'jquery';
import 'vendor/jasmine-jquery';
@@ -41,8 +42,8 @@ jasmine.getJSONFixtures().fixturesPath = FIXTURES_PATH;
beforeAll(() => {
jasmine.addMatchers(
jasmineDiff(jasmine, {
- colors: true,
- inline: true,
+ colors: !__karma__.config.isCi,
+ inline: !__karma__.config.isCi,
}),
);
jasmine.addMatchers(customMatchers);
diff --git a/yarn.lock b/yarn.lock
index 57ec6096549..27ba4c6ac0b 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -4220,6 +4220,13 @@ karma-jasmine@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/karma-jasmine/-/karma-jasmine-1.1.2.tgz#394f2b25ffb4a644b9ada6f22d443e2fd08886c3"
+karma-junit-reporter@^1.2.0:
+ version "1.2.0"
+ resolved "https://registry.yarnpkg.com/karma-junit-reporter/-/karma-junit-reporter-1.2.0.tgz#4f9c40cedfb1a395f8aef876abf96189917c6396"
+ dependencies:
+ path-is-absolute "^1.0.0"
+ xmlbuilder "8.2.2"
+
karma-mocha-reporter@^2.2.5:
version "2.2.5"
resolved "https://registry.yarnpkg.com/karma-mocha-reporter/-/karma-mocha-reporter-2.2.5.tgz#15120095e8ed819186e47a0b012f3cd741895560"
@@ -7139,6 +7146,10 @@ xdg-basedir@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-3.0.0.tgz#496b2cc109eca8dbacfe2dc72b603c17c5870ad4"
+xmlbuilder@8.2.2:
+ version "8.2.2"
+ resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-8.2.2.tgz#69248673410b4ba42e1a6136551d2922335aa773"
+
xmlhttprequest-ssl@~1.5.4:
version "1.5.5"
resolved "https://registry.yarnpkg.com/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz#c2876b06168aadc40e57d97e81191ac8f4398b3e"