{"id":16623862,"url":"https://github.com/koleok/jest-coverage-ratchet","last_synced_at":"2025-03-16T22:30:45.088Z","repository":{"id":57280264,"uuid":"91861638","full_name":"Koleok/jest-coverage-ratchet","owner":"Koleok","description":"Uses jest coverage output to raise acceptable coverage threshold to current coverage","archived":false,"fork":false,"pushed_at":"2020-02-25T04:52:16.000Z","size":97,"stargazers_count":41,"open_issues_count":6,"forks_count":12,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-13T03:25:18.284Z","etag":null,"topics":["coverage","coverage-report","coverage-testing","javascript","jest","node","ratchet","testing"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/Koleok.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":null,"support":null}},"created_at":"2017-05-20T03:06:59.000Z","updated_at":"2023-11-07T12:45:37.000Z","dependencies_parsed_at":"2022-09-19T19:01:29.791Z","dependency_job_id":null,"html_url":"https://github.com/Koleok/jest-coverage-ratchet","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Koleok%2Fjest-coverage-ratchet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Koleok%2Fjest-coverage-ratchet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Koleok%2Fjest-coverage-ratchet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Koleok%2Fjest-coverage-ratchet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Koleok","download_url":"https://codeload.github.com/Koleok/jest-coverage-ratchet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221668362,"owners_count":16860631,"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":["coverage","coverage-report","coverage-testing","javascript","jest","node","ratchet","testing"],"created_at":"2024-10-12T03:25:14.957Z","updated_at":"2024-10-27T11:25:49.545Z","avatar_url":"https://github.com/Koleok.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jest-coverage-ratchet\n\nRaises `jest`'s minimum coverage thresholds _(per category)_ if current coverage is higher.\n\n## What does it do?\n\nLets say you have some [jest coverage thresholds](https://facebook.github.io/jest/docs/configuration.html#coveragethreshold-object) set in the `package.json` for your project at the following values:\n```javascript\n{\n  \"branches\": 30,\n  \"functions\": 30,\n  \"lines\": 30,\n  \"statements\": 50,\n}\n```\n\nthen you get inspired one day and write lots of tests. Now your actual coverage summary might look like this:\n```javascript\n{\n  \"branches\": 50,\n  \"functions\": 60,\n  \"lines\": 77,\n  \"statements\": 50,\n}\n```\n\nGreat 🌸‼ Except you'd really like your accomplishment to set the new standard for test coverage in this project. **`jest-coverage-ratchet` just does that automatically by looking at your current coverage summary, comparing it to your specified coverage thresholds, and updating the minimum for any threshold that is higher in the summary.**\n\nSo given the previous values, running this script will update your coverage thresholds specified in the `jest` key of `package.json` to the following values:\n```javascript\n{\n  \"branches\": 50,\n  \"functions\": 60,\n  \"lines\": 77,\n  \"statements\": 50,\n}\n```\n\n## Installation\n\nJust add as a dev dependency to your project like\n```bash\nnpm install --save-dev jest-coverage-ratchet\n```\n\nor\n\n```bash\nyarn add --dev jest-coverage-ratchet\n```\n\nI recommend then using the binary `jest-coverage-ratchet` as part of a [`prepush` hook](https://github.com/typicode/husky).\n\n## Assumptions\n\nI know what happens [when you assume](http://www.urbandictionary.com/define.php?term=Assume), but `jest-coverage-ratchet` makes the following assumptions about your project.\n\n- `jest` has been run for project at least once with `--coverage` so that there is a valid file at the path `./coverage/coverage-summary.json` _(alternatively pass a path with `--coverageSummaryPath` of `./your/path/to/coverage-summary.json`)_\n- `jest` configuration object is present in the `package.json` that specifies at least:\n  - [coverage thresholds](https://facebook.github.io/jest/docs/configuration.html#coveragethreshold-object) _(alternatively pass a path with `--configPath` of `./your/path/to/jest.config.json`)_\n  - `'json-summary'` in your jest config's [reporters list](https://facebook.github.io/jest/docs/configuration.html#coveragereporters-array-string) like so:\n  ```javascript\n  {\n    // ...\n    \"jest\": {\n      \"coverageReporters\": [\n        \"json-summary\"\n      ],\n      \"coverageThreshold\": {\n        \"global\": {\n          \"branches\": Number,\n          \"functions\": Number,\n          \"lines\": Number,\n          \"statements\": Number,\n        }\n      }\n    },\n    // ...\n  }\n  ```\n\nShould this tool support things like piping the coverage data in as an argument? Of course it should. If you want to build that and send a PR I will be all smiles 😀✨. If not then you probably see me do it _eventually_.\n\n## Questions?\nJust submit an issue or a PR, I'm no elitist.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoleok%2Fjest-coverage-ratchet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoleok%2Fjest-coverage-ratchet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoleok%2Fjest-coverage-ratchet/lists"}