{"_id":"@dchiesa/mocha-badge-generator","name":"@dchiesa/mocha-badge-generator","dist-tags":{"latest":"0.9.0"},"versions":{"0.9.0":{"name":"@dchiesa/mocha-badge-generator","version":"0.9.0","description":"Mocha reporter which outputs badge with the number of tests passed and failed.","main":"src/index.js","bin":{"mbg":"bin/mbg.js","mocha-badge-generator":"bin/mbg.js"},"scripts":{"build-cli":"clp --config=bin/optionDefinitions.js cli.svg","bin":"./bin/mbg.js","lint":"eslint .","json-test-report":"mocha --reporter json test > test/fixtures/test-report-mbg.json","nyc":"nyc --all --reporter=text mocha","test":"npm run lint && npm run nyc","test-watch":"mocha -w","cov":"nyc --all --reporter=text npm test","coverage":"nyc --all --reporter=lcov npm test"},"nyc":{"exclude":[".eslintrc.js","coverage","test"]},"repository":{"type":"git","url":"git+https://github.com/DinoChiesa/mocha-badge-generator.git"},"keywords":["mocha","reporter","badge","shield","svg"],"author":{"name":"Dino Chiesa","email":"dchiesa@google.com"},"contributors":[{"name":"Ian Dela Cruz","email":"iandc76@gmail.com"},{"name":"Brett Zamir"}],"engines":{"node":">= 12.22.0","npm":">= 8.3.0"},"license":"MIT","bugs":{"url":"https://github.com/DinoChiesa/mocha-badge-generator/issues"},"homepage":"https://github.com/DinoChiesa/mocha-badge-generator","dependencies":{"badge-up":"https://registry.npmjs.org/@rpl/badge-up/-/badge-up-3.0.0.tgz","command-line-basics":"^0.8.0","es6-template-strings":"^2.0.1","fast-glob":"^3.2.11"},"devDependencies":{"chai":"^4.2.0","command-line-publish":"^0.7.0","eslint":"^7.12.1","mocha":"^10.0.0","nyc":"^15.1.0","svg2png":"^4.1.1"},"publishConfig":{"access":"public"},"prettier":{"printWidth":80,"tabWidth":4,"useTabs":false,"semi":true,"singleQuote":true,"trailingComma":"all","bracketSpacing":true,"arrowParens":"avoid"},"overrides":{"nth-check":"^2.0.1","package-json":"^8.1.0","uuid":"^7.0.3"},"gitHead":"e61f1df3816c2da6df30153a6bb2697197d97079","_id":"@dchiesa/mocha-badge-generator@0.9.0","_nodeVersion":"16.17.0","_npmVersion":"8.3.0","dist":{"integrity":"sha512-x7oVszc/rSa3JN+V1Yr0Dw7MZOjwoQmS1lOGj0noJq21CSIhcl8XXIUV+cIdK1noXAAoTaTSK0WMZpTaAcvr8w==","shasum":"2cd274f96855d2a1028524f1d8f15b0bc37498dc","tarball":"https://registry.npmjs.org/@dchiesa/mocha-badge-generator/-/mocha-badge-generator-0.9.0.tgz","fileCount":9,"unpackedSize":33952,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFFZ6bPxCyQQjYzQl9gbN5HcN+DBt31zEoJyzov9XCXaAiBChofjRhKYSCqMbwbGjpA1mK0rJQ98qu2CKXRvfaIM9w=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjNiXrACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmrj2g//YkshfsdasmcSe65txD3+eOjp2lfnQsEGgaNGHTakYBT1YZ6w\r\nhR2DQy+XlfgIfWmOJYKd5wXS440OJxUuZCqt+7M6bNM/dZV4wf+rbgl/KBhZ\r\nwTevz5F8K5vTKRUxkuj6sGHO+WMGixMr80NOpFTy5CBTFH7kORpHkc/wsik6\r\nhGSJdnI+I/UI7vpN3HN2gP0Kot4y+Or90oq5U5PI42eTTFbssGnMqOMJePjB\r\nNaK1CsHsb/9hRrsZKsjVwKQqxIvwp8o+anAvCaVmz4z8aRH2fycWNm3fZBSE\r\nEWcVi7Vx6djyfUKqFa6T5nSmY/KgvSJVULoOuAOzjA0toKKMTubR/CZcXym9\r\nBUu89KsKjYzuRQSOLZkGrV1IE9E4nxQCbRsentcpo+9X5Em+2HetElajNU19\r\ncPUQUM21knHK6+bioNmBBYucAhkCbWBRAU3DVH08krGv8xtTZn1Am2Bp5WPe\r\nDnWMWh7uezbnhSYYWwZrZ7KN8qSils7ENqbgGa8l0mgZeLMU8+lnLDtPkW9N\r\nSuol8rkGIchn6TGGt84Z8Yx3S/M6RqZc3Zb7Dqaw14+YnJmlfEU4wqtJQjYJ\r\nT3AhR3+zKbppOqlrsUDrhziaBnQJARjsGtaiLpFmFKQLFXk5FI7RNtWBI0M3\r\n0HW0oYuuCEzuybCZHR6Ac6GmMOofRV52sQ4=\r\n=TdEA\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"dinochiesa","email":"TheRealDinoChiesa@gmail.com"},"directories":{},"maintainers":[{"name":"dinochiesa","email":"TheRealDinoChiesa@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mocha-badge-generator_0.9.0_1664493035448_0.2084195922182437"},"_hasShrinkwrap":false}},"time":{"created":"2022-09-29T23:10:35.392Z","0.9.0":"2022-09-29T23:10:35.685Z","modified":"2022-09-29T23:10:35.835Z"},"maintainers":[{"name":"dinochiesa","email":"TheRealDinoChiesa@gmail.com"}],"description":"Mocha reporter which outputs badge with the number of tests passed and failed.","homepage":"https://github.com/DinoChiesa/mocha-badge-generator","keywords":["mocha","reporter","badge","shield","svg"],"repository":{"type":"git","url":"git+https://github.com/DinoChiesa/mocha-badge-generator.git"},"contributors":[{"name":"Ian Dela Cruz","email":"iandc76@gmail.com"},{"name":"Brett Zamir"}],"author":{"name":"Dino Chiesa","email":"dchiesa@google.com"},"bugs":{"url":"https://github.com/DinoChiesa/mocha-badge-generator/issues"},"license":"MIT","readme":"# Mocha Badge Generator\n\n![Test](https://raw.githubusercontent.com/ianpogi5/mocha-badge-generator/master/test/badge.svg?sanitize=true)\n[![Build Status](https://travis-ci.com/ianpogi5/mocha-badge-generator.png?branch=master)](https://travis-ci.com/ianpogi5/mocha-badge-generator)\n[![codecov](https://codecov.io/gh/ianpogi5/mocha-badge-generator/branch/master/graph/badge.svg)](https://codecov.io/gh/ianpogi5/mocha-badge-generator)\n[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/ianpogi5/mocha-badge-generator/issues)\n\n[![https://nodei.co/npm/mocha-badge-generator.png?downloads=true&downloadRank=true&stars=true](https://nodei.co/npm/mocha-badge-generator.png?downloads=true&downloadRank=true&stars=true)](https://www.npmjs.com/package/mocha-badge-generator)\n\n## @dpc/mocha-badge-generator\n\nThis is a patched version of mocha-badge-generator that fixes up the dependency on `es6-template-strings`.\nWithout this fix, running mbg will result in a \"module not found\" error.\n\nThis version of mbg also changes the badge-up dependency from\n[badge-up](https://www.npmjs.com/package/badge-up) to\n[@rpl/badge-up](https://www.npmjs.com/package/@rpl/badge-up), which fixes some\nvulnerabilities in the Yahoo-owned module.\n\n## Summary\n\nNo need for 3rd party to generate badge for your tests. You can generate it locally by running your test script.\n\nMocha Badge Generator is a [Mocha](https://mochajs.org/) reporter which outputs a badge (SVG or PNG file) with the number of tests passed and failed which you can embed in your readme file.\n\n## Install\n\n```bash\nnpm install mocha-badge-generator --save-dev\n```\n\n## Usage\n\nIn your `package.json`, add reporter to your test script.\n\n```json\n{\n    \"scripts\": {\n        \"test\": \"mocha --reporter mocha-badge-generator\",\n    }\n}\n```\n\nDefault output file is `test/badge.svg`.\n\n## Configuration\n\nYou can change the output by defining Mocha `--reporter-options` or environment variables in your test script.\n\n| `--reporter-option` | Env variable | Default  | Description |\n|---------------------|--------------| :------: |-------------|\n| badge_subject | MOCHA_BADGE_GEN_SUBJECT  | Tests | The text that appears the left side of the badge. |\n| badge_ok_color | MOCHA_BADGE_GEN_OK_COLOR | 44cc11 (brightgreen) | The color when all tests pass. Colors may be a 6-digit hex code or a named CSS color. If upgrading from <= 0.3.0, please note that if you were not relying on the default colors, the CSS named colors may differ from the [`badge-up` builtin colors](https://github.com/yahoo/badge-up/blob/b6f073624fee0d5ee5341a90a9cfb9ff6ae52034/index.js#L51-L64) we were using previously; use the corresponding hex code (without the `#`), and convert to 6 digits (e.g., `4C1` to `44CC11`). May now also be followed by a comma and `s{ffffff}` to add a different stroke color. |\n| badge_ko_color | MOCHA_BADGE_GEN_KO_COLOR | e05d44 (red) | The color when at least 1 test fail. See above for possible colors (and a note about upgrading from <= 0.3.0). |\n| badge_output | MOCHA_BADGE_GEN_OUTPUT | ./test/badge.svg | Path of the output file. |\n| badge_format | MOCHA_BADGE_GEN_FORMAT | svg | Output file format. Possible values are \"svg\" and \"png\". However, please note that for format \"png\", while versions <= 0.3.0 bundled `svg2png`, you must now add `svg2png` yourself (e.g., to your `dependencies` or `devDependencies`).  |\n| badge_template | MOCHA_BADGE_GEN_TEMPLATE | `\"${passes}/${total}\"` | ES6 template for formatting the results; will be passed `passes`, `failures`, `total`, `duration`, `speeds` (with `fast`, `medium`, and `slow` property counts). |\n| badge_threshold | MOCHA_BADGE_GEN_THRESHOLD | 0 |  Number of acceptable failures (such that if exceeded, `badge_ko_color` will be used in place of `badge_ok_color`). |\n| badge_slow_threshold | MOCHA_BADGE_GEN_SLOW_THRESHOLD | N/A | Indicates a maximum number of slow tests beyond which the tests will be considered a failure (such that if the amount is exceeded, `badge_ko_color` will be used in place of `badge_ok_color`). No default as only checked if present. |\n| badge_duration_threshold | MOCHA_BADGE_GEN_DURATION_THRESHOLD | N/A | Indicates a maximum duration in milliseconds beyond which the tests will be considered a failure (such that if the duration is exceeded, `badge_ko_color` will be used in place of `badge_ok_color`). No default as only checked if present. |\n\nSample config for changing output to PNG.\n\n```json\n{\n    \"scripts\": {\n        \"test\": \"mocha --reporter mocha-badge-generator --reporter-options=badge_format=png,badge_output=badge.png\",\n    }\n}\n```\n\nAlternatively, you may use environmental variables:\n\n```json\n{\n    \"scripts\": {\n        \"test\": \"MOCHA_BADGE_GEN_FORMAT=png MOCHA_BADGE_GEN_OUTPUT=badge.png mocha --reporter mocha-badge-generator\",\n    }\n}\n```\n\n## Adding to your README\n\n```markdown\n![Test](test/badge.svg)\n```\n\n If you want the badge to show in npm, use the following format.\n\n```markdown\n![Test](https://raw.githubusercontent.com/ianpogi5/mocha-badge-generator/master/test/badge.svg?sanitize=true)\n```\n\nChange `ianpogi5/mocha-badge-generator` to your own github repo.\n\n## Other methods\n\nWhile the main method may be sufficient, certain environments (such as Cypress)\nmay call for creating a badge based on already-generated JSON test file results\n(e.g., when merging multiple test results into a single file).\n\n### `makeBadge`\n\n```js\nconst {makeBadge} = require('mocha-badge-generator/makeBadge');\nmakeBadge({\n    // REQUIRED\n    passes,\n    failures,\n    // OPTIONAL\n    options: {\n        // See above for expected values\n        badge_subject,\n        badge_ok_color,\n        badge_ok_color,\n        badge_output,\n        badge_format,\n        badge_template,\n        badge_threshold,\n        badge_slow_threshold,\n        badge_duration_threshold\n    }\n});\n```\n\n### `makeBadgeFromJSONFile`\n\nYou can make a badge out of a Mocha JSON reporter report (as a JSON file).\n\n```js\nconst {makeBadgeFromJSONFile} = require('mocha-badge-generator/makeBadge');\nmakeBadgeFromJSONFile({\n    // REQUIRED\n    // This JSON file expects the structure: `{stats: {passes, failures}}`\n    file: '/path/to/JSON/file'\n    // Options\n    // Milliseconds which will be considered \"slow\" (and by Mocha's algorithm,\n    //  any more than half of this will still be considered \"medium\"); this\n    //  is not available in test reports even when individual tests add\n    //  their own calls to `slow`, so reporting on `speeds` may only be\n    //  useful if your tests have no idiosyncratic speed expectations.\n    //  When using `makeBadge` (i.e., using with Mocha while it is running),\n    //  however, there is no such limitation, and no need to specify `slow`\n    //  as an option to `makeBadge` (just supply it as usual to Mocha).\n    slow: 75,\n    // See above for expected values\n    badge_subject,\n    badge_ok_color,\n    badge_ok_color,\n    badge_output,\n    badge_format,\n    badge_template,\n    badge_threshold,\n    badge_slow_threshold,\n    badge_duration_threshold\n});\n```\n\n## CLI\n\nThe `makeBadgeFromJSONFile` functionality is exposed from the command line:\n\n![cli.svg](cli.svg)\n","readmeFilename":"README.md"}