Skip to content

Commit f367d8c

Browse files
committed
Add test coverage configuration and update workflows
Configured Jest for test coverage reporting, updated test script in `package.json` to include coverage, and modified GitHub Actions workflow to run tests with coverage. Updated `.gitignore` to exclude coverage reports.
1 parent 08c9f93 commit f367d8c

4 files changed

Lines changed: 18 additions & 1 deletion

File tree

.github/workflows/node.js.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ jobs:
2828
cache: 'npm'
2929
- run: npm ci
3030
- run: npm run build --if-present
31-
- run: npm test
31+
- name: Run tests with coverage
32+
run: npm run test:coverage

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.idea/
22
node_modules/
3+
coverage/
34

45
*.env

jest.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,19 @@ export default {
55
},
66
testEnvironment: 'node',
77
testMatch: ['**/__tests__/**/*.js', '**/?(*.)+(spec|test).js'],
8+
collectCoverageFrom: [
9+
"src/**/*.{js,jsx}",
10+
"!src/public/**",
11+
"!**/node_modules/**"
12+
],
13+
coverageDirectory: "coverage",
14+
coverageThreshold: {
15+
global: {
16+
branches: 17,
17+
functions: 16,
18+
lines: 10,
19+
statements: 10
20+
}
21+
},
822
verbose: true
923
};

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"type": "module",
66
"scripts": {
77
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
8+
"test:coverage": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage",
89
"start": "node src/notes-api-server.js"
910
},
1011
"keywords": [],

0 commit comments

Comments
 (0)