Skip to content

Commit 1d11184

Browse files
committed
Conditionally enabled coverage
1 parent e196500 commit 1d11184

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

.github/workflows/end_to_end_tests.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ jobs:
4242
name: playwright-coverage
4343
path: coverage-playwright/
4444
retention-days: 30
45+
46+
env:
47+
ENABLE_COVERAGE: "true"

.github/workflows/unit_tests.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ jobs:
3333
name: unit-coverage
3434
path: coverage-unit/
3535
retention-days: 30
36+
37+
env:
38+
ENABLE_COVERAGE: "true"

docs/tests.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ To execute the tests seeing the browser add the `--headed` flag or the `--debug`
2121
Coverage for the unit tests:
2222

2323
```
24-
npx vitest run --coverage.enabled --coverage.provider=istanbul --coverage.include=src --coverage.reporter=json --coverage.all
24+
ENABLE_COVERAGE=true npx vitest run --coverage.enabled --coverage.provider=istanbul --coverage.include=src --coverage.reporter=json --coverage.all
2525
```
2626

2727
Warning: coverage takes some time using the option `--coverage.all`.
2828

29-
Coverage for the playwright tests is automatically collected when running `npx playwright test`.
29+
Coverage for the playwright tests is automatically collected when running `ENABLE_COVERAGE=true npx playwright test`.
3030

3131
To generate a merged html report:
3232

vite.config.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,34 @@ const packageJsonFile = fileURLToPath(new URL('package.json', import.meta.url));
77
const packageJsonData = readFileSync(packageJsonFile);
88
const pkg = JSON.parse(packageJsonData);
99

10+
const enableIstanbul = process.env['ENABLE_COVERAGE'];
11+
1012
/** @type {import('vite').UserConfig} */
1113
const config = {
1214
plugins: [
1315
sveltekit(),
14-
istanbul({
15-
include: 'src/*',
16-
exclude: ['node_modules', 'tests', 'static'],
17-
extension: ['.js', '.svelte'],
18-
requireEnv: false,
19-
forceBuildInstrument: true
20-
})
16+
enableIstanbul &&
17+
istanbul({
18+
include: 'src/*',
19+
exclude: ['node_modules', 'tests', 'static'],
20+
extension: ['.js', '.svelte'],
21+
requireEnv: false,
22+
forceBuildInstrument: true
23+
})
2124
],
2225
define: {
2326
__APP_VERSION__: JSON.stringify(pkg.version)
2427
},
28+
build: {
29+
sourcemap: true
30+
},
2531
test: {
2632
globals: true,
2733
include: ['**/__tests__/**/*.?(c|m)[jt]s?(x)'],
2834
coverage: {
2935
provider: 'istanbul',
3036
reporter: ['text', 'json', 'html'],
31-
reportsDirectory: './coverage-unit',
37+
reportsDirectory: './coverage-unit'
3238
}
3339
},
3440
optimizeDeps: {

0 commit comments

Comments
 (0)