Skip to content

Commit

Permalink
add jest coverage threshold check in prepush and github action covera…
Browse files Browse the repository at this point in the history
…ge table
  • Loading branch information
harley-harris committed Jan 5, 2024
1 parent e67b26a commit 45938f7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
20 changes: 20 additions & 0 deletions .github/workflows/jest-coverage-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Jest Coverage Report

on: [pull_request]

jobs:
jest-coverage-report:

runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20.x'

- name: Coverage Report
uses: ArtiomTr/jest-coverage-report-action@v2
2 changes: 1 addition & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run test
npm run coverage
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ module.exports = {
roots: ['<rootDir>/src', '<rootDir>/test'],
testPathIgnorePatterns: ['/node_modules/', '/lib/'],
collectCoverageFrom: ['./src/**/*.ts'],
coverageThreshold: {
global: {
lines: 95,
},
},
preset: 'ts-jest',
testEnvironment: 'node',
verbose: true,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"lint": "eslint '{src,test}/**/*.ts'",
"lint:fix": "eslint '{src,test}/**/*.ts' --fix",
"test": "jest",
"coverage:ci": "npm ci && npm run build && jest --ci --json --coverage --testLocationInResults --outputFile=report.json",
"coverage": "jest --coverage",
"prepare": "husky install",
"prepublish": "[ ! -d node_modules ] && npm ci; tsc",
Expand Down

0 comments on commit 45938f7

Please sign in to comment.