Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test coverage report to README.md and Github actions #152

Merged
merged 3 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: "coverage"
on:
pull_request_target:
branches:
- develop
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ArtiomTr/jest-coverage-report-action@v2
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
yarn lint
yarn test
yarn test --coverage
yarn build
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,20 @@ yarn install
yarn test
```

#### Generating Test Coverage Report

To generate a test coverage report using Jest run the following command in your terminal:

```sh
npx jest --coverage
```

If you're using macOS, you can directly access the coverage report in your browser by opening the following URL:

```
file:///Users/<userName>/sandbag/coverage/lcov-report/index.html
```

#### How to publish a new release to NPM
Submit a PR with commit message `[npm publish]`

Expand Down
10 changes: 9 additions & 1 deletion jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node'
testEnvironment: 'node',
coverageThreshold: {
global: {
branches: 20,
functions: 20,
lines: 20,
statements: -999999 // Exceptionally high allowance for uncovered statements to start
}
}
}
Loading