From 3ee3149d504d6bcb19e167b89baa821828ed018d Mon Sep 17 00:00:00 2001 From: Remi REGNAULT Date: Thu, 30 Nov 2023 08:30:14 +0100 Subject: [PATCH] get modifications --- .drone.yml | 8 ++++---- API-Project/jest.config.js | 13 ------------- API-Project/package-lock.json | 19 +++++++++++++++++++ API-Project/package.json | 12 +++++++++++- 4 files changed, 34 insertions(+), 18 deletions(-) delete mode 100644 API-Project/jest.config.js diff --git a/.drone.yml b/.drone.yml index 9c63a1b..e678012 100644 --- a/.drone.yml +++ b/.drone.yml @@ -25,7 +25,7 @@ steps: - npm install - npm run build - - name: test + - name: publish-jest-reports image: node:latest environment: DB_USERNAME: @@ -40,7 +40,7 @@ steps: from_secret: SECRET_DB_PORT commands: - cd ./API-Project - - npm run test + - npm run test:coverage depends_on: [ api-build ] - name: docker-build-and-push @@ -102,5 +102,5 @@ steps: - unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ - export PATH=$SONAR_SCANNER_HOME/bin:$PATH - export SONAR_SCANNER_OPTS="-server" - - sonar-scanner -D sonar.projectKey=LeftOvers_Api -D sonar.sources=. -D sonar.host.url=https://codefirst.iut.uca.fr/sonar - depends_on: [ api-build ] \ No newline at end of file + - sonar-scanner -D sonar.projectKey=LeftOvers_Api -D sonar.sources=. -D sonar.host.url=https://codefirst.iut.uca.fr/sonar -D sonar.testExecutionReportPaths=./coverage/sonar-report.xml + depends_on: [ publish-jest-reports ] \ No newline at end of file diff --git a/API-Project/jest.config.js b/API-Project/jest.config.js deleted file mode 100644 index 333758b..0000000 --- a/API-Project/jest.config.js +++ /dev/null @@ -1,13 +0,0 @@ -module.exports = { - preset: 'ts-jest', - testEnvironment: 'node', - moduleNameMapper: { - '^@/(.*)$': '/src/$1', - }, - testMatch: ['/tests/**/*.spec.ts'], - globals: { - 'ts-jest': { - tsconfig: 'tsconfig.json', - }, - }, -}; \ No newline at end of file diff --git a/API-Project/package-lock.json b/API-Project/package-lock.json index 5acf996..9787305 100644 --- a/API-Project/package-lock.json +++ b/API-Project/package-lock.json @@ -27,6 +27,7 @@ "@types/pg": "^8.10.9", "@types/supertest": "^2.0.16", "jest": "^29.7.0", + "jest-sonar-reporter": "^2.0.0", "ts-jest": "^29.1.1" } }, @@ -3662,6 +3663,18 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/jest-sonar-reporter": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/jest-sonar-reporter/-/jest-sonar-reporter-2.0.0.tgz", + "integrity": "sha512-ZervDCgEX5gdUbdtWsjdipLN3bKJwpxbvhkYNXTAYvAckCihobSLr9OT/IuyNIRT1EZMDDwR6DroWtrq+IL64w==", + "dev": true, + "dependencies": { + "xml": "^1.0.1" + }, + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/jest-util": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.7.0.tgz", @@ -5661,6 +5674,12 @@ "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, + "node_modules/xml": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz", + "integrity": "sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw==", + "dev": true + }, "node_modules/xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", diff --git a/API-Project/package.json b/API-Project/package.json index 140209f..3cb773a 100644 --- a/API-Project/package.json +++ b/API-Project/package.json @@ -8,7 +8,8 @@ "build": "tsup src/server.ts --format cjs --clean", "dev": "nodemon --watch src -e js,ts,json --exec \"ts-node src/server.ts\"", "test": "jest", - "test:watch": "jest --watchAll" + "test:watch": "jest --watchAll", + "test:coverage": "jest --coverage" }, "author": "", "license": "ISC", @@ -31,6 +32,15 @@ "@types/pg": "^8.10.9", "@types/supertest": "^2.0.16", "jest": "^29.7.0", + "jest-sonar-reporter": "^2.0.0", "ts-jest": "^29.1.1" + }, + "jest": { + "testResultsProcessor": "jest-sonar-reporter", + "preset": "ts-jest" + }, + "jestSonar": { + "reportPath": "./reports", + "reportFile": "report.test.xml" } }