{"id":23924559,"url":"https://github.com/moos/istanbul-diff","last_synced_at":"2025-04-12T02:33:10.181Z","repository":{"id":19862454,"uuid":"88122321","full_name":"moos/istanbul-diff","owner":"moos","description":"diffs two istanbul code coverage json reports.","archived":false,"fork":false,"pushed_at":"2022-12-30T17:48:32.000Z","size":101,"stargazers_count":7,"open_issues_count":5,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T22:06:59.067Z","etag":null,"topics":["code-coverage","coveralls","istanbul"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/moos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-13T03:42:49.000Z","updated_at":"2025-03-12T20:25:05.000Z","dependencies_parsed_at":"2023-01-13T20:38:20.805Z","dependency_job_id":null,"html_url":"https://github.com/moos/istanbul-diff","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moos%2Fistanbul-diff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moos%2Fistanbul-diff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moos%2Fistanbul-diff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moos%2Fistanbul-diff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moos","download_url":"https://codeload.github.com/moos/istanbul-diff/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248506901,"owners_count":21115503,"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":["code-coverage","coveralls","istanbul"],"created_at":"2025-01-05T19:15:33.804Z","updated_at":"2025-04-12T02:33:10.146Z","avatar_url":"https://github.com/moos.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"istanbul-diff\n=============\n\n[![NPM version](https://img.shields.io/npm/v/wordpos.svg)](https://www.npmjs.com/package/istanbul-diff)\n\nUses [jsondiffpatch](https://github.com/benjamine/jsondiffpatch)\nto find \u0026 report diffs between two [istanbul](https://github.com/gotwarlost/istanbul) JSON \ncode coverage summaries in the vein of [coveralls](https://coveralls.io/).\n\n```shell\n$ npm install istanbul-diff\n```\n```shell\n$ istanbul-diff test/data/coverage-summary.1.json test/data/coverage-summary.2.json\nCoverage increased +60% (10) lines. That's good. (istanbul/)\n```\n\n## CLI Usage\n```\nUSAGE:\n  istanbul-diff coverage-summary-before.json coverage-summary-after.json\nOptions:\n  --depth \u003cn\u003e    diff to depth n\n  --pick \u003ct\u003e     pick out \u003ct\u003e diff, e.g. lines.pct (comma separated)\n  --lines        include linesCovered (can be very long!)\n  --json         output json diff (always exits successfully)\n  --json-compact output compact json diff (always exits successfully)\n  --detail [\u003cw\u003e] detailed report. \u003cw\u003e=lines,statements,functions,branches or blank for all\n  --recurse      recurse through sub folders (up to depth), otherwise print only root');\n\n  --nomotivate   disabling compliment, or not!\n  --nocolor      disable colorized output\n  --nofail       do not exit with code 1 if coverage decreases\n  --brief        suppress no-change messages');\n```\nJob will exit with code `1` (fail) if coverage has regressed (decreased), unless `--nofail` is given. \n\nNormally only the `lines` metric is reported.  This can be overridden by passing `--detail`.\n\nCoverage JSON summary files are generated through istanbul's `json-summary` report, e.g.:\n```shell\n$ istanbul cover --report html --report json-summary .\n```\nAlternatively, use the [moos fork](https://www.npmjs.com/package/istanbul-moos) of istanbul and generate \n`text-folder` report which makes a much more compact `folder-summary.json` files.\n\nExample:\n```shell\n$ istanbul-diff test/data/coverage-summary.1.json test/data/coverage-summary.4.json --detail lines,functions\nCoverage delta:  -60% (-10) lines, +10% (10) functions (istanbul/)\n```\n\nYou can also get a terse summary text of a _single_ JSON summary report:\n ```shell\n$ istanbul-diff test/data/coverage-summary.1.json\nCoverage 80.53% (1836) lines. You outdid yourself today. (istanbul/)\n```\n\n## API Usage\n### #diff(before, after, options)\nGet diff between two coverage JSON summaries.\n```\n * before {Object} - json-summary data, e.g.:\n *     { total: {lines: {total:75,covered:59,skipped:0,pct:78.67}, statements: {...}, ... }\n * after {Object} - json-summary data\n * options {object}\n *    pick {string|array} - 'lines' or 'lines.covered' or array of such. see #pick()\n *    depth {number} - see #dip()\n *    ignoreAdded {boolean} - ignore added diffs\n *    ignoreRemoved {boolean} - ignore removed diffs\n *    ignoreLinesCovered {boolean} - ignore lines covered (detail: true)\n * @returns {object} - for each key in before/after summaries, return diff value\n```\nExample:\n```js\nvar istanbulDiff = require('istanbul-diff'),\n  cov1 =  JSON.parse(fs.readFileSync('data/coverage-summary1.json')),\n  cov2 =  JSON.parse(fs.readFileSync('data/coverage-summary2.json')),\n  diff = istanbulDiff.diff(cov1, cov2);\nconsole.log(diff);\n```\nOutput:\n```js\n{ total:\n   { lines: { covered: 7, pct: 7.6 },\n     statements: { covered: 7, pct: 7.1 },\n     branches: { covered: 10, pct: 13 } },\n  '/dev/git/istanbul-diff/lib/index.js':\n   { lines: { covered: 7, pct: 12 },\n     statements: { covered: 7, pct: 11 },\n     branches: { covered: 10, pct: 23 } } }\n```\n\n### #dip(diff, depth, options)\nPrune diff object beyond given depth\n```\n * diff {object} - the diff'd hash\n * depth {number} - root is at 0 (unless options is given)\n * options {object}\n *    rootDepth {number} - the depth of the root node\n * returns {object}\n```\n\n### #pick(diff, props)\nCherry pick given properties\n```\n * diff {object} - the diff'd hash\n * props {string|Array} - key map to get, e.g., 'lines.covered', or 'lines'\n * returns {object}\n```\n\n### #print(diff, options)\nPretty print difference in coverage\n```\n * diff {object} - the diff'd hash\n * options {object} - \n *   nocolor {boolean} - don't use ANSI colors in output message\n *   nomotivate {boolean} - don't add motivation message\n *   detail {string} - comma separated list of: lines,statements,functions,branches\n *   recurse {boolean} - recurse through sub folders\n *   brief {boolean} - suppress no-change messages\n * @returns {msg: String, regressed: Boolean} \n```\n`regressed` return key is true if _any_ of the metric diffs were negative (used by CLI to return correct exit code).\n\n### #print.compliment(positive)\nPrint a [nicejob](https://github.com/moos/nicejob) message.\n```\n * positive {boolean} - whether compliment should be positive or negative \n * @returns {string} \n```\n\n## Test\n```shell\n$ npm run test \n```\n\nTo get self coverage report (make sure `istanbul` is installed):\n```shell\n$ npm run test-cover \u0026\u0026 open coverage/index.html \n```\n\n## Samples\nSample scripts for increasing, decreasing, and same coverage.\n```shell\n$ npm run sample-inc\n$ npm run sample-dec\n$ npm run sample-same -- --detail\n$ npm run sample-single\n```\n## Change log\n- v2.0.0 - `--json` now returns correct JSON (thanks @nickofthyme) (:warning: **breaking change** to CLI).  New `--json-compact`.  Fix readme typos (thanks @maxwu). \n- v1.1.4 - clean up npm package\n- v1.1.3 - Added explicit lodash dependency (Apr 2017)\n- v1.1.2 - Added _single_ file summary reporting \u0026 node 4.x (LTS) compatibility (Apr 2017)\n-v1.1.0 - Renamed data files to coverage-summary to emphasize content.  Reformat output text (Apr 2017)\n- v1.0.6 - Added --recurse and --brief options, fixed --nomotivate and --nocolor, add sample scripts (Apr 2017)\n- v1.0.0 - Initial release (Apr 2017)\n\n\n## License\nMIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoos%2Fistanbul-diff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoos%2Fistanbul-diff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoos%2Fistanbul-diff/lists"}