Skip to content

Commit 4435eb5

Browse files
committed
chore(test-coverage): configure coverage
- add config in vitest.config.ts - add test:coverage in package.json - remove unconventional scripts\- configure ci to report coverage
1 parent 9e6aefb commit 4435eb5

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,8 @@ jobs:
3535
- name: Lint
3636
run: pnpm lint
3737

38-
- name: Run tests
39-
run: pnpm test
38+
- name: Run tests with coverage
39+
run: pnpm test:coverage
40+
41+
- name: Report test coverage
42+
uses: davelosert/vitest-coverage-report-action@v2

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,11 @@
4242
],
4343
"scripts": {
4444
"build": "rm -rf lib && tsc --project tsconfig.build.json",
45-
"build:watch": "tsc --watch",
46-
"eslint-check": "eslint-config-prettier src/index.ts",
4745
"lint": "eslint src",
4846
"lint:fix": "eslint src --fix",
4947
"test": "vitest",
5048
"typecheck": "tsc --noEmit",
51-
"typecheck:watch": "tsc --noEmit --watch"
49+
"test:coverage": "vitest --coverage"
5250
},
5351
"dependencies": {
5452
"graphql": "^16.0.0",

vitest.config.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
11
// @ts-check
2-
import { defineConfig } from "vitest/config";
2+
import { coverageConfigDefaults, defineConfig } from "vitest/config";
33

44
export default defineConfig({
55
test: {
66
include: ["src/**/*.test.ts"],
77
setupFiles: ["vitest.setup.ts"],
8+
coverage: {
9+
provider: "v8",
10+
reporter: ["text", "json-summary", "json"],
11+
include: ["src/**/*.ts"],
12+
exclude: ["src/**/{index,types}.ts", ...coverageConfigDefaults.exclude],
13+
experimentalAstAwareRemapping: true,
14+
ignoreEmptyLines: true,
15+
all: true,
16+
thresholds: {
17+
statements: 70,
18+
branches: 58,
19+
functions: 70,
20+
lines: 70,
21+
},
22+
},
823
},
924
});

0 commit comments

Comments
 (0)