aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorRevanshu Paliwal <revanshu.paliwal@sonarsource.com>2023-10-05 10:26:18 +0200
committersonartech <sonartech@sonarsource.com>2023-10-12 20:02:51 +0000
commitd9546e30ba6cef9be308a506cdd87cc52db18694 (patch)
tree2a45d3e7641c1ff598384ca459ee8ce1e3697e23 /server
parent4444e5fdfbb3d013d1630e47dad2a3ac288204f8 (diff)
downloadsonarqube-d9546e30ba6cef9be308a506cdd87cc52db18694.tar.gz
sonarqube-d9546e30ba6cef9be308a506cdd87cc52db18694.zip
SONAR-20409 Data dog monitoring for frontend unit test
Diffstat (limited to 'server')
-rw-r--r--server/sonar-web/config/jest/DataDogReporter.js (renamed from server/sonar-web/config/jest/ElasticSearchReporter.js)30
-rw-r--r--server/sonar-web/design-system/jest.config.js16
-rw-r--r--server/sonar-web/jest.config.js4
3 files changed, 30 insertions, 20 deletions
diff --git a/server/sonar-web/config/jest/ElasticSearchReporter.js b/server/sonar-web/config/jest/DataDogReporter.js
index 2650402e165..08ac6c8dc83 100644
--- a/server/sonar-web/config/jest/ElasticSearchReporter.js
+++ b/server/sonar-web/config/jest/DataDogReporter.js
@@ -21,9 +21,6 @@
const fs = require('fs');
const ES_ITEM_CATEGORY = 'Validate-UT-Frontend';
-const ES_ITEM_KIND = 'testcase';
-const ES_ITEM_OPERATION = 'total';
-const ES_ITEM_SUITE = 'Standalone';
module.exports = class ElasticSearchReporter {
constructor(globalConfig, options) {
@@ -60,20 +57,19 @@ module.exports = class ElasticSearchReporter {
const timestamp = new Date(testClassResult.perfStats.start).toISOString();
const testClass = this.stripFilePath(testClassResult.testFilePath);
- return testClassResult.testResults.map(testResult => ({
- commit,
- build,
- category: ES_ITEM_CATEGORY,
- kind: ES_ITEM_KIND,
- operation: ES_ITEM_OPERATION,
- suite: ES_ITEM_SUITE,
- measureClass: '',
- measureMethod: '',
- timestamp,
- testClass,
- testMethod: testResult.fullName,
- duration: testResult.duration
- }));
+ return testClassResult.testResults
+ .filter((test) => test.status === 'failed')
+ .map((testResult) => ({
+ commit,
+ build,
+ category: ES_ITEM_CATEGORY,
+ timestamp,
+ testClass,
+ testMethod: testResult.fullName,
+ exceptionClass: '',
+ exceptionMessage: testResult.failureMessages[0],
+ exceptionLogs: testResult.failureMessages[0],
+ }));
}
onRunComplete(contexts, { testResults }) {
diff --git a/server/sonar-web/design-system/jest.config.js b/server/sonar-web/design-system/jest.config.js
index 21af92326f2..a2399e4f397 100644
--- a/server/sonar-web/design-system/jest.config.js
+++ b/server/sonar-web/design-system/jest.config.js
@@ -52,11 +52,25 @@ module.exports = {
setupFilesAfterEnv: ['<rootDir>/config/jest/SetupReactTestingLibrary.ts'],
snapshotSerializers: ['@emotion/jest/serializer'],
testEnvironment: 'jsdom',
- testPathIgnorePatterns: ['<rootDir>/config/jest', '<rootDir>/node_modules', '<rootDir>/scripts', '<rootDir>/lib'],
+ testPathIgnorePatterns: [
+ '<rootDir>/config/jest',
+ '<rootDir>/node_modules',
+ '<rootDir>/scripts',
+ '<rootDir>/lib',
+ ],
testRegex: '(/__tests__/.*|\\-test)\\.(ts|tsx|js)$',
transform: {
'^.+\\.(t|j)sx?$': ['babel-jest', babelConfig],
},
transformIgnorePatterns: ['/node_modules/(?!(d3-.+))/'],
+ reporters: [
+ 'default',
+ [
+ '../config/jest/DataDogReporter.js',
+ {
+ outputFilepath: '/tmp/ut-ts-designsystem-test-monitoring.log',
+ },
+ ],
+ ],
testTimeout: 60000,
};
diff --git a/server/sonar-web/jest.config.js b/server/sonar-web/jest.config.js
index 4aa418c407d..0d7280374d9 100644
--- a/server/sonar-web/jest.config.js
+++ b/server/sonar-web/jest.config.js
@@ -56,9 +56,9 @@ module.exports = {
},
],
[
- './config/jest/ElasticSearchReporter.js',
+ './config/jest/DataDogReporter.js',
{
- outputFilepath: '/tmp/ut-ts-web-monitoring.log',
+ outputFilepath: '/tmp/ut-ts-web-test-monitoring.log',
},
],
['jest-slow-test-reporter', { numTests: 5, warnOnSlowerThan: 10000, color: true }],