From 74e5f0e50936e3796b04f6e2188efb8ec1126e30 Mon Sep 17 00:00:00 2001 From: Johannes Fleck Date: Thu, 17 Sep 2026 15:17:53 +0200 Subject: [PATCH 1/2] feat(tests): add coverage --- package.json | 1 + vite.config.ts | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2289b662..15140ba5 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "lint": "prettier --check --ignore-path .prettierignore . && eslint .", "lint:fix": "prettier --write --ignore-path .prettierignore . && eslint . --fix", "test:unit": "vitest run", + "test:unit:coverage": "vitest run --coverage", "test:e2e": "node --env-file=.env.test node_modules/.bin/vite build && playwright test", "test:e2e:garage": "./e2e/run-garage-tests.sh", "test:e2e:ui": "playwright test --ui", diff --git a/vite.config.ts b/vite.config.ts index 7f115657..b666c0d8 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -19,8 +19,17 @@ export default defineConfig({ test: { coverage: { provider: 'v8', - reporter: ['json', 'json-summary'], - reportsDirectory: './coverage' + reporter: ['text', 'html', 'json', 'json-summary'], + reportsDirectory: './coverage', + // Without `include`, files that no test ever imports are silently omitted from the + // report instead of showing as 0% — set it so untested modules are actually visible. + include: ['src/**/*.{ts,svelte}'], + exclude: [ + 'src/**/*.d.ts', + 'src/lib/paraglide/**', + 'src/lib/editor/generated/**', + 'src/lib/server/migrations/**' + ] }, expect: { requireAssertions: true }, projects: [ From 2ffb5d4385d567689790a500d67b0f7f5aad7eb2 Mon Sep 17 00:00:00 2001 From: Johannes Fleck Date: Thu, 17 Sep 2026 15:18:12 +0200 Subject: [PATCH 2/2] feat(tests): add coverage to ci --- .github/workflows/pr_checks.yaml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr_checks.yaml b/.github/workflows/pr_checks.yaml index f1b7216b..94d0dedb 100644 --- a/.github/workflows/pr_checks.yaml +++ b/.github/workflows/pr_checks.yaml @@ -64,6 +64,9 @@ jobs: unit-tests: name: Unit Tests runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write # required by the coverage report action to comment on the PR steps: - name: Checkout uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -82,8 +85,16 @@ jobs: - name: Install Playwright browsers run: npx playwright install --with-deps chromium - - name: Run unit tests - run: npm run test:unit + - name: Run unit tests with coverage + run: npm run test:unit:coverage + + # Reports overall + diff coverage as a job summary and a sticky PR comment. + # Informational only — coverage is not currently enforced as a merge gate. + - name: Coverage report + if: always() && github.event_name == 'pull_request' + uses: davelosert/vitest-coverage-report-action@c4bbc33a89b7ace0e63d35f1f7d4bcee31155a73 # v2.13.0 + with: + file-coverage-mode: changes e2e-with-garage: name: E2E Tests with Garage S3