{"id":18952214,"url":"https://github.com/step-security/jest-coverage-report-action","last_synced_at":"2026-03-29T03:30:19.885Z","repository":{"id":258142086,"uuid":"872365935","full_name":"step-security/jest-coverage-report-action","owner":"step-security","description":"Track your code coverage in every pull request.","archived":false,"fork":false,"pushed_at":"2025-02-14T04:53:41.000Z","size":7825,"stargazers_count":0,"open_issues_count":11,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-02-14T05:28:26.358Z","etag":null,"topics":["step-security-maintained-actions"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/step-security.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-14T10:07:45.000Z","updated_at":"2025-02-14T04:53:46.000Z","dependencies_parsed_at":"2025-01-28T16:22:18.084Z","dependency_job_id":"d5b2cfe3-8643-4a31-b688-0c2e614d2384","html_url":"https://github.com/step-security/jest-coverage-report-action","commit_stats":null,"previous_names":["step-security/jest-coverage-report-action"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/step-security%2Fjest-coverage-report-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/step-security%2Fjest-coverage-report-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/step-security%2Fjest-coverage-report-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/step-security%2Fjest-coverage-report-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/step-security","download_url":"https://codeload.github.com/step-security/jest-coverage-report-action/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239951594,"owners_count":19723904,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["step-security-maintained-actions"],"created_at":"2024-11-08T13:31:44.723Z","updated_at":"2026-03-29T03:30:19.820Z","avatar_url":"https://github.com/step-security.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jest coverage report 🧪\n\n\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"PR Comment example\" width=\"540\" src=\"./img/Github-comment-screenshot.jpg\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    A GitHub action that reports about your code coverage in every pull request.\n\u003c/p\u003e\n\n\nThis action uses [Jest](https://github.com/facebook/jest) to extract code coverage, and comments it on pull request. Inspired by [Size-limit action](https://github.com/andresz1/size-limit-action/). Features:\n\n-   **Reporting** code coverage on each pull request. 📃\n-   **Rejecting** pull request, if coverage is under threshold. ❌\n-   **Comparing** coverage with base branch. 🔍\n-   Showing spoiler in the comment for all **new covered files**. 🆕\n-   Showing spoiler in the comment for all files, in which **coverage was reduced**. 🔻\n-   Failed tests \u0026 uncovered line **annotations** 📢\n\n\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"PR Comment example\" width=\"540\" src=\"./img/Rejected-PR-screenshot.jpg\"\u003e\n\u003c/p\u003e\n\n## Usage\n\n1. Install and configure [Jest](https://github.com/facebook/jest).\n2. Create new action inside `.github/workflows`:\n\n**Minimal configuration**\n\n```yml\nname: 'coverage'\non:\n    pull_request:\n        branches:\n            - master\n            - main\njobs:\n    coverage:\n        runs-on: ubuntu-latest\n        steps:\n            - uses: actions/checkout@v3\n            - uses: step-security/jest-coverage-report-action@v2\n```\n\n3. Pay attention to the action parameters. You can specify custom [threshold](#specify-threshold) or [test script](#customizing-test-script)\n4. That's it!\n\n## Forks with no write permission\n\nIf you're seeing this error in your action's console:\n\n```\nHttpError: Resource not accessible by integration\n    at /home/runner/work/_actions/step-security/jest-coverage-report-action/v2/dist/index.js:8:323774\n    at processTicsAndRejections (node:internal/process/task_queues:96:5)\n    at async /home/runner/work/_actions/step-security/jest-coverage-report-action/v2/dist/index.js:64:2535\n    at async Ie (/home/runner/work/_actions/step-security/jest-coverage-report-action/v2/dist/index.js:63:156)\n    at async S_ (/home/runner/work/_actions/step-security/jest-coverage-report-action/v2/dist/index.js:64:2294)\n```\n\n\u003e **Warning**\n\u003e\n\u003e This brings worse DX - you can test action only when it is merged into your main branch. **Any changes to the workflow file will be taken only after merging them to the main branch**\n\n## Custom token\n\nBy default, this action takes `github.token` variable to publish reports on your PR. You can overwrite this property by specifying:\n\n```yml\nwith:\n    github-token: ${{ secrets.SECRET_TOKEN }}\n```\n\n## Specify threshold\n\nThis action automatically suports jest's [`coverageThreshold`](https://jestjs.io/docs/configuration#coveragethreshold-object) property.\nJust add into your `jest.config.js` file:\n\n```js\nmodule.exports = {\n    coverageThreshold: {\n        global: {\n            lines: 80,\n        },\n    },\n};\n```\n\n## Custom working directory\n\nIf you want to run this action in custom directory, specify `working-directory`:\n\n```yml\nwith:\n    working-directory: \u003cdir\u003e\n```\n\n## Customizing test script\n\nThis action automatically adds necessary flags to your test script. The default script is:\n\n```\nnpx jest\n```\n\nSo you don't need to specify additional flags - action will handle them\nautomatically. So, after adding necessary flags, action will run this command:\n\n```\nnpx jest --ci --json --coverage --testLocationInResults --outputFile=report.json\n```\n\nBut you do not need to specify these flags manually. Also, you can use different package manager, `yarn` for example:\n\n```yml\nwith:\n    test-script: yarn jest\n```\n\nOr, if you would like to run a script from your `package.json`:\n\n```yml\nwith:\n    test-script: npm test\n```\n\n## Usage with `yarn` `pnpm`, or `bun`\n\nBy default, this action will install your dependencies using `npm`. If you are using `yarn`, `pnpm`, or `bun`, you can specify it in the `package-manager` option:\n\n```yml\nwith:\n    package-manager: yarn\n```\n\nor\n\n```yml\nwith:\n    package-manager: pnpm\n```\n\nor\n\n```yml\nwith:\n    package-manager: bun\n```\n\n## Use existing test report(s)\n\nTo bypass running unit tests, you can pass the filepath to the current report.json\n\n```yml\nwith:\n    coverage-file: ./coverage/report.json\n    base-coverage-file: ./coverage/master/report.json\n```\n\n-   `coverage-file` is the filepath to the JSON coverage report for the current pull request.\n-   `base-coverage-file` is the filepath to the JSON coverage report from the branch your pull request is merging into.\n\nFor example, you can save every test run to an artifact and then download and reference them here.\n\n## Opt-out coverage comparison features\n\nYou can opt-out coverage comparison features to speed-up action. To achieve this, firstly, manually collect coverage to `report.json` file. Then, specify these options for the action:\n\n```yml\nwith:\n    coverage-file: report.json\n    base-coverage-file: report.json\n```\n\n## Skipping steps\n\n\u003e Note: this option affects only coverage for the \"head\" branch. For skipping steps of \"base\" branch, see [`base-coverage-file`](#use-existing-test-reports) option.\n\nBy default, this action will install dependencies and run the tests for you, generating the coverage report. Alternatively, you can skip these steps using the `skip-step` option.\n\n```yml\nwith:\n    skip-step: all\n```\n\nAccepted values are:\n\n-   `none` (default) - all steps will be run\n-   `install` - skip installing dependencies\n-   `all` - skip installing dependencies _and_ running the test script\n\n## Change annotations\n\nTo change annotations, you have to set the annotations option as shown below:\n\n```yml\nwith:\n    annotations: none\n```\n\nAccepted values are:\n\n-   `all` (default) - Will annotate sections of your code that failed tests or test did not cover\n-   `none` - Turns off annotations\n-   `coverage` - Will annotate those sections of your code that test did not cover. Limited to changed lines when used on a Pull Request\n-   `failed-tests` - Will annotate those sections of your code that failed test\n\n## Outputs\n\nBy default, action attaches comment to a pull request or commit. However, if you want to use other action for publishing report, you can specify `output: report-markdown`:\n\n```yaml\n- uses: step-security/jest-coverage-report-action@v2\n    # give the id for the step, to access outputs in another step.\n    id: coverage\n    with:\n        # tell to the action to not attach comment.\n        output: report-markdown\n- uses: marocchino/sticky-pull-request-comment@v2\n    with:\n        # pass output from the previous step by id.\n        message: ${{ steps.coverage.outputs.report }}\n```\n\nAlso, you can use this data on other platforms. For instance, you can send report to your [Slack](https://github.com/slackapi/slack-github-action) or [Jira](https://github.com/atlassian/gajira-comment).\n\n\u003e **Note**: Working examples of integrations with different platforms are much appreciated! Feel free to open a [PR](https://github.com/step-security/jest-coverage-report-action/pulls).\n\nAvailable options are:\n* `comment` - Attach comment to PR or commit, depending on event type, which triggered an action.\n* `report-markdown` - Generate output \"report\", with report contents in markdown format.\n\nAlso, you can combine these options:\n\n```yml\nwith:\n    # This will attach comment to a PR and generate markdown output.\n    output: comment, report-markdown\n```\n\n## Pull Request Number\n\nIf you are using the `push` event to trigger this action, by default it does not know which PR to comment on or the base branch of the PR to compare code coverage with.\n\nYou can pass the `prnumber` to the action so that coverage change can be run and comments will be updated on each push, instead of creating a new comment with each run of the action.\n\nYou can find the PR number with a number of methods, the [jwalton/gh-find-current-pr](https://github.com/jwalton/gh-find-current-pr) action makes it easy:\n\n```yml\nname: 'coverage'\non:\n    push:\n        branches:\n            - master\n            - main\njobs:\n    coverage:\n        permissions:\n            checks: write\n            pull-requests: write\n            contents: write\n        runs-on: ubuntu-latest\n        steps:\n            - uses: actions/checkout@v1\n            - uses: jwalton/gh-find-current-pr@v1\n                id: findPr\n            - uses: step-security/jest-coverage-report-action@v2\n                with:\n                   prnumber: ${{ steps.findPr.outputs.number }}\n```\n\n## Customizing report title\n\nIf you're running this action multiple times (for instance, when dealing with monorepos), you'll need to distinguish reports from different runs. To do so, you can use the `custom-title` property:\n\n```yaml\nwith:\n    custom-title: Coverage report for backend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstep-security%2Fjest-coverage-report-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstep-security%2Fjest-coverage-report-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstep-security%2Fjest-coverage-report-action/lists"}