diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index af230f2..7b398e4 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -16,4 +16,18 @@ jobs: node-version: ${{ env.NODE_VERSION }} - run: npm ci - run: npm run format:check - - run: npm test + - run: npm test --coverage + # sonarcloud scan + - name: SonarQube Scan + uses: SonarSource/sonarqube-scan-action@v4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONARCLOUD_TEST_COVERAGE }} + with: + args: > + -Dsonar.projectKey=bitvavo_node-bitvavo-api + -Dsonar.organization=bitvavo + -Dsonar.sources=. + -Dsonar.exclusions=**/node_modules/**,**/dist/**,**/coverage/**,**/e2e/**,**/cypress/**,**/github-trigger/** + -Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info + -Dsonar.sourceEncoding=UTF-8 diff --git a/.gitignore b/.gitignore index 56cd3cc..d70e3bd 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ node_modules/ ### IDE ### .idea/ .vscode/ +coverage/ \ No newline at end of file diff --git a/jest.config.js b/jest.config.js index e34a824..89b4207 100644 --- a/jest.config.js +++ b/jest.config.js @@ -5,6 +5,16 @@ const config = { // The glob patterns Jest uses to detect test files testMatch: ['/test/*.spec.js'], + + testEnvironment: 'node', // Set the environment for Node.js + collectCoverage: true, // Enable code coverage + coverageDirectory: 'coverage', // Directory to save coverage reports + collectCoverageFrom: [ + '!**/node_modules/**', // Exclude node_modules + '!**/dist/**', // Exclude built files + '!jest.config.js', // Exclude the config file + ], + coverageReporters: ['lcov'], // Specify formats for coverage reports } module.exports = config