From 51d02b308638c31d6cd4c46125ce9155fc033ecf Mon Sep 17 00:00:00 2001 From: Malena Ebert <63863184+malena-ebert-sonarsource@users.noreply.github.com> Date: Wed, 20 Jan 2021 14:10:36 +0100 Subject: [PATCH] BUILD-857 Add junit report format for jest tests. --- server/sonar-docs/package.json | 11 ++++++++++- server/sonar-docs/yarn.lock | 22 +++++++++++++++++++++- server/sonar-web/jest.config.js | 16 +++++++++++++++- server/sonar-web/package.json | 3 ++- server/sonar-web/yarn.lock | 25 +++++++++++++++++++++++++ 5 files changed, 73 insertions(+), 4 deletions(-) diff --git a/server/sonar-docs/package.json b/server/sonar-docs/package.json index dffe2c5adb4..3ffba49e22e 100644 --- a/server/sonar-docs/package.json +++ b/server/sonar-docs/package.json @@ -56,6 +56,7 @@ "graphql-code-generator": "0.5.2", "jest": "25.1.0", "jest-fetch-mock": "2.1.2", + "jest-junit": "12.0.0", "prettier": "1.19.1", "react-test-renderer": "16.8.5", "remark": "11.0.2", @@ -74,7 +75,7 @@ "lint-report": "eslint --ext js,ts,tsx -f json -o eslint-report.json src", "ts-check": "tsc --noEmit", "validate": "yarn lint && yarn ts-check && yarn format-check && yarn test", - "validate-ci": "yarn lint-report && yarn test --coverage", + "validate-ci": "yarn lint-report && yarn test --coverage --ci --reporters=default --reporters=jest-junit", "check-ci": "yarn ts-check && yarn format-check" }, "prettier": { @@ -110,5 +111,13 @@ "\\.js$": "babel-jest", "\\.(ts|tsx)$": "ts-jest" } + }, + "jest-junit": { + "outputDirectory": "build/test-results/test-jest", + "outputName": "junit.xml", + "ancestorSeparator": " > ", + "suiteNameTemplate": "{filename}", + "classNameTemplate": "{classname}", + "titleTemplate": "{title}" } } diff --git a/server/sonar-docs/yarn.lock b/server/sonar-docs/yarn.lock index 09bbc33d46a..016390d87fd 100644 --- a/server/sonar-docs/yarn.lock +++ b/server/sonar-docs/yarn.lock @@ -9105,6 +9105,16 @@ jest-jasmine2@^25.1.0: pretty-format "^25.1.0" throat "^5.0.0" +jest-junit@12.0.0: + version "12.0.0" + resolved "https://repox.jfrog.io/repox/api/npm/npm/jest-junit/-/jest-junit-12.0.0.tgz#3ebd4a6a84b50c4ab18323a8f7d9cceb9d845df6" + integrity sha1-Pr1KaoS1DEqxgyOo99nM652EXfY= + dependencies: + mkdirp "^1.0.4" + strip-ansi "^5.2.0" + uuid "^3.3.3" + xml "^1.0.1" + jest-leak-detector@^25.1.0: version "25.1.0" resolved "https://repox.jfrog.io/repox/api/npm/npm/jest-leak-detector/-/jest-leak-detector-25.1.0.tgz#ed6872d15aa1c72c0732d01bd073dacc7c38b5c6" @@ -10279,6 +10289,11 @@ mkdirp@0.5.1, mkdirp@0.x, mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.1: dependencies: minimist "0.0.8" +mkdirp@^1.0.4: + version "1.0.4" + resolved "https://repox.jfrog.io/repox/api/npm/npm/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" + integrity sha1-PrXtYmInVteaXw4qIh3+utdcL34= + modularscale@^1.0.2: version "1.0.2" resolved "https://repox.jfrog.io/repox/api/npm/npm/modularscale/-/modularscale-1.0.2.tgz#4a8f13af32a5e5214fc6e2cfc529064abfd7d877" @@ -15110,7 +15125,7 @@ utils-merge@1.0.1: resolved "https://repox.jfrog.io/repox/api/npm/npm/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM= -uuid@3.4.0, uuid@^3.4.0: +uuid@3.4.0, uuid@^3.3.3, uuid@^3.4.0: version "3.4.0" resolved "https://repox.jfrog.io/repox/api/npm/npm/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" integrity sha1-sj5DWK+oogL+ehAK8fX4g/AgB+4= @@ -15634,6 +15649,11 @@ xml-name-validator@^3.0.0: resolved "https://repox.jfrog.io/repox/api/npm/npm/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" integrity sha1-auc+Bt5NjG5H+fsYH3jWSK1FfGo= +xml@^1.0.1: + version "1.0.1" + resolved "https://repox.jfrog.io/repox/api/npm/npm/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5" + integrity sha1-eLpyAgApxbyHuKgaPPzXS0ovweU= + xmlchars@^2.1.1: version "2.2.0" resolved "https://repox.jfrog.io/repox/api/npm/npm/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb" diff --git a/server/sonar-web/jest.config.js b/server/sonar-web/jest.config.js index 6b1d649224e..8dea5867955 100644 --- a/server/sonar-web/jest.config.js +++ b/server/sonar-web/jest.config.js @@ -26,5 +26,19 @@ module.exports = { transform: { '\\.js$': 'babel-jest', '\\.(ts|tsx)$': 'ts-jest' - } + }, + reporters: [ + 'default', + [ + 'jest-junit', + { + outputDirectory: 'build/test-results/test-jest', + outputName: 'junit.xml', + ancestorSeparator: ' > ', + suiteNameTemplate: '{filename}', + classNameTemplate: '{classname}', + titleTemplate: '{title}' + } + ] + ] }; diff --git a/server/sonar-web/package.json b/server/sonar-web/package.json index 7a9939c4807..59ce83e4657 100644 --- a/server/sonar-web/package.json +++ b/server/sonar-web/package.json @@ -100,6 +100,7 @@ "glob-promise": "3.4.0", "html-webpack-plugin": "3.2.0", "jest": "25.1.0", + "jest-junit": "12.0.0", "lint-staged": "7.3.0", "lodash-webpack-plugin": "0.11.5", "mini-css-extract-plugin": "0.9.0", @@ -132,7 +133,7 @@ "lint-report": "eslint --ext js,ts,tsx -f json -o eslint-report.json src/main/js", "ts-check": "tsc --noEmit", "validate": "yarn lint && yarn ts-check && yarn format-check && yarn test", - "validate-ci": "yarn lint-report && yarn test --coverage", + "validate-ci": "yarn lint-report && yarn test --coverage --ci", "check-ci": "yarn ts-check && yarn format-check", "precommit": "yarn ts-check && lint-staged" }, diff --git a/server/sonar-web/yarn.lock b/server/sonar-web/yarn.lock index 6b5120833ff..e7abaa60b53 100644 --- a/server/sonar-web/yarn.lock +++ b/server/sonar-web/yarn.lock @@ -7161,6 +7161,16 @@ jest-jasmine2@^25.1.0: pretty-format "^25.1.0" throat "^5.0.0" +jest-junit@12.0.0: + version "12.0.0" + resolved "https://repox.jfrog.io/repox/api/npm/npm/jest-junit/-/jest-junit-12.0.0.tgz#3ebd4a6a84b50c4ab18323a8f7d9cceb9d845df6" + integrity sha1-Pr1KaoS1DEqxgyOo99nM652EXfY= + dependencies: + mkdirp "^1.0.4" + strip-ansi "^5.2.0" + uuid "^3.3.3" + xml "^1.0.1" + jest-leak-detector@^25.1.0: version "25.1.0" resolved "https://repox.jfrog.io/repox/api/npm/npm/jest-leak-detector/-/jest-leak-detector-25.1.0.tgz#ed6872d15aa1c72c0732d01bd073dacc7c38b5c6" @@ -8224,6 +8234,11 @@ mkdirp@0.x, mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.1: dependencies: minimist "0.0.8" +mkdirp@^1.0.4: + version "1.0.4" + resolved "https://repox.jfrog.io/repox/api/npm/npm/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" + integrity sha1-PrXtYmInVteaXw4qIh3+utdcL34= + moo@^0.4.3: version "0.4.3" resolved "https://repox.jfrog.io/repox/api/npm/npm/moo/-/moo-0.4.3.tgz#3f847a26f31cf625a956a87f2b10fbc013bfd10e" @@ -12260,6 +12275,11 @@ uuid@^3.0.1, uuid@^3.3.2: resolved "https://repox.jfrog.io/repox/api/npm/npm/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131" integrity sha1-G0r0lV6zB3xQHCOHL8ZROBFYcTE= +uuid@^3.3.3: + version "3.4.0" + resolved "https://repox.jfrog.io/repox/api/npm/npm/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" + integrity sha1-sj5DWK+oogL+ehAK8fX4g/AgB+4= + v8-compile-cache@^2.0.3: version "2.1.0" resolved "https://repox.jfrog.io/repox/api/npm/npm/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz#e14de37b31a6d194f5690d67efc4e7f6fc6ab30e" @@ -12660,6 +12680,11 @@ xml-name-validator@^3.0.0: resolved "https://repox.jfrog.io/repox/api/npm/npm/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" integrity sha1-auc+Bt5NjG5H+fsYH3jWSK1FfGo= +xml@^1.0.1: + version "1.0.1" + resolved "https://repox.jfrog.io/repox/api/npm/npm/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5" + integrity sha1-eLpyAgApxbyHuKgaPPzXS0ovweU= + xmlchars@^2.1.1: version "2.2.0" resolved "https://repox.jfrog.io/repox/api/npm/npm/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb" -- 2.39.5