Skip to content

Commit e266810

Browse files
committed
Update coverage setup
1 parent 7fcdab0 commit e266810

File tree

4 files changed

+48
-7
lines changed

4 files changed

+48
-7
lines changed

.codecov.yml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,33 @@
1+
coverage:
2+
status:
3+
project:
4+
default:
5+
target: 80%
6+
threshold: 1%
7+
patch:
8+
default:
9+
target: 80%
10+
threshold: 1%
11+
12+
ignore:
13+
- '**/*.test.*'
14+
- '**/node_modules/**'
15+
- '**/dist/**'
16+
17+
comment:
18+
layout: 'reach, diff, flags, files'
19+
behavior: default
20+
require_changes: false
21+
require_base: no
22+
require_head: yes
23+
24+
parsers:
25+
gcov:
26+
branch_detection:
27+
conditional: yes
28+
loop: yes
29+
method: no
30+
macro: no
31+
132
codecov:
2-
branch: master
33+
require_ci_to_pass: yes

.github/workflows/ci.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ jobs:
2727
- name: Install dependencies
2828
run: npm install
2929

30-
- name: Run tests
31-
run: npm test
30+
- name: Run tests with coverage
31+
run: npm test -- --coverage
3232

33-
# - name: Upload coverage to Codecov
34-
# uses: codecov/codecov-action@v4
35-
# with:
36-
# token: ${{ secrets.CODECOV_TOKEN }}
33+
- name: Upload coverage to Codecov
34+
uses: codecov/codecov-action@v4
35+
with:
36+
token: ${{ secrets.CODECOV_TOKEN }}
37+
files: ./coverage/coverage-final.json
38+
flags: node-${{ matrix.node-version }}
39+
name: codecov-umbrella
40+
fail_ci_if_error: true

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"test:watch": "vitest --watch",
4848
"build": "npx webpack",
4949
"watch": "npx webpack --watch",
50+
"test:coverage": "vitest run --coverage",
5051
"preversion": "npm test && npm run build && cp dist/list.min.js docs/assets/javascripts/list.min.js && cp dist/list.min.js.map docs/assets/javascripts/list.min.js.map && git add dist && git add docs/assets/javascripts",
5152
"postversion": "git push --follow-tags origin master && cp package.json docs/_data/pkg.json && git add docs/_data/pkg.json && git commit -m \"pkg.json update\""
5253
},

vitest.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,10 @@ export default defineConfig({
44
test: {
55
environment: 'jsdom', // <-- detta är det viktiga!
66
globals: true,
7+
coverage: {
8+
reporter: ['text', 'lcov', 'html'],
9+
reportsDirectory: './coverage',
10+
exclude: ['node_modules', 'dist', '**/*.test.*'],
11+
},
712
},
813
})

0 commit comments

Comments
 (0)