From ae45ba7ca8a7edb60a347ee16827169615795115 Mon Sep 17 00:00:00 2001 From: Timo De Meyst Date: Fri, 4 Apr 2025 17:31:39 +0200 Subject: [PATCH] actions: frontend test coverage wordt gereport door de workflow --- .github/workflows/frontend-testing.yml | 17 ++++++++++++++++- frontend/package.json | 1 + frontend/vitest.config.ts | 6 ++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/.github/workflows/frontend-testing.yml b/.github/workflows/frontend-testing.yml index ff7bde4d..23950914 100644 --- a/.github/workflows/frontend-testing.yml +++ b/.github/workflows/frontend-testing.yml @@ -38,6 +38,12 @@ jobs: if: '! github.event.pull_request.draft' runs-on: [self-hosted, Linux, X64] + permissions: + # Required to checkout the code + contents: read + # Required to put a comment into the pull-request + pull-requests: write + strategy: matrix: node-version: [22.x] @@ -51,4 +57,13 @@ jobs: node-version: ${{ matrix.node-version }} cache: 'npm' - run: npm ci - - run: npm run test:unit -w frontend + - run: npm run test:coverage -w frontend + - name: 'Report Frontend Coverage' + # Set if: always() to also generate the report if tests are failing + # Only works if you set `reportOnFailure: true` in your vite config as specified above + if: always() + uses: davelosert/vitest-coverage-report-action@v2 + with: + name: 'Frontend' + json-summary-path: './frontend/coverage/coverage-summary.json' + json-final-path: './frontend/coverage/coverage-final.json' diff --git a/frontend/package.json b/frontend/package.json index e6ce1426..105331f0 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -13,6 +13,7 @@ "format-check": "prettier --check src/", "lint": "eslint . --fix", "test:unit": "vitest --run", + "test:coverage": "vitest --run --coverage.enabled true", "test:e2e": "playwright test" }, "dependencies": { diff --git a/frontend/vitest.config.ts b/frontend/vitest.config.ts index ba2d72b6..9f561462 100644 --- a/frontend/vitest.config.ts +++ b/frontend/vitest.config.ts @@ -9,6 +9,12 @@ export default mergeConfig( environment: "jsdom", exclude: [...configDefaults.exclude, "e2e/**"], root: fileURLToPath(new URL("./", import.meta.url)), + coverage: { + reporter: ['text', 'json-summary', 'json'], + // If you want a coverage reports even if your tests are failing, include the reportOnFailure option + reportOnFailure: true, + exclude: ['**/*config*'], + }, }, }), );