{"name":"mochawesome","version":"8.0.0","keywords":["mocha","reporter","json","html"],"author":{"name":"Adam Gruber"},"license":"MIT","_id":"mochawesome@8.0.0","maintainers":[{"name":"adamgruber","email":"talknmime@gmail.com"}],"homepage":"https://github.com/adamgruber/mochawesome#readme","bugs":{"url":"https://github.com/adamgruber/mochawesome/issues"},"c8":{"lines":99,"include":["src/*.js"],"branches":90,"reporter":["lcov","html","text-summary"],"functions":100,"statements":99,"check-coverage":true},"dist":{"shasum":"f0f2801e060f2d22271d953e51f28b53a14777ba","tarball":"http://registry-npm.ywwl.com/mochawesome/download/mochawesome-8.0.0.tgz","fileCount":11,"integrity":"sha512-wVJiOHkMPirW1cBAzW98bWZk+97q7N28op3sw6AMLuxAKyisqOO2D6fnGFk1KJhvLK915u6TMFyl9Hnazj2XMQ==","signatures":[{"sig":"MEYCIQCDHedexg8kyU4uQTUVvnlelpyg4SG1pPgCqOpUFlD8rwIhAK+WngoMB/Ir0GkThiB/nE4CwwIPJriOAYVWnmBHfIaB","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEYCIQDTGK1sXnLfnNj4Osms7E1DbvUFBsd7yUrphJMeS+Jl/wIhANg329q+TMXDh6f+eqgUAgXgPDyCnS8I3Z9uvqlC77gP","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/mochawesome@8.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":35369,"size":12027,"noattachment":false,"key":"/mochawesome/-/mochawesome-8.0.0.tgz"},"main":"src/mochawesome.js","engines":{"node":">=22"},"gitHead":"c756529acb8c02ab2350c78f9f0fd1f4b763de1c","scripts":{"tdd":"npm run lint && c8 mocha --config test/.mocharc.json --watch","lint":"eslint src test*","test":"npm run lint && c8 mocha --config test/.mocharc.json && npm run test:parity","prepare":"husky","test:fn":"mocha test-functional --config test-functional/.mocharc.json","test:ctx":"mocha test-functional/test-context.js --config test-functional/.mocharc.json","test:mem":"mocha test-functional/mem-test.js --config test-functional/.mocharc.json","test:par":"mocha test-parallel --parallel --config test-parallel/.mocharc.json","test:prog":"node ./test-programmatic","test:parity":"node test-parity/run.js","test:parity:update":"node test-parity/run.js --update","test:parity:published":"node test-parity/published.js"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:02524f05-fb93-4dfe-ba89-225170c9927b"}},"prettier":{"semi":true,"tabWidth":2,"arrowParens":"avoid","singleQuote":true,"trailingComma":"es5"},"repository":{"url":"git+https://github.com/adamgruber/mochawesome.git","type":"git"},"_npmVersion":"12.0.2","description":"A gorgeous reporter for Mocha.js","directories":{},"lint-staged":{"*.js":"eslint --cache --fix","*.{js,css,md}":"prettier --write"},"_nodeVersion":"22.23.1","dependencies":{"diff":"^5.2.0","json-stringify-safe":"^5.0.1","mochawesome-report-generator":"^6.3.2"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^11.0.0","husky":"^9.1.7","mocha":"^11.7.6","sinon":"^22.0.0","eslint":"^10.6.0","should":"^13.2.3","globals":"^17.7.0","prettier":"^3.9.4","@eslint/js":"^10.0.1","proxyquire":"^2.1.3","lint-staged":"^17.0.8","eslint-config-prettier":"^10.1.8"},"peerDependencies":{"mocha":">=8"},"_npmOperationalInternal":{"tmp":"tmp/mochawesome_8.0.0_1785417310662_0.32282677247847524","host":"s3://npm-registry-packages-npm-production"},"readme":"# mochawesome\n\n[![npm](https://img.shields.io/npm/v/mochawesome.svg?style=flat-square)](https://www.npmjs.com/package/mochawesome) [![npm downloads](https://img.shields.io/npm/dm/mochawesome.svg?style=flat-square)](https://www.npmjs.com/package/mochawesome) [![node](https://img.shields.io/node/v/mochawesome.svg?style=flat-square)](https://www.npmjs.com/package/mochawesome) [![Node.js CI](https://github.com/adamgruber/mochawesome/actions/workflows/nodejs.yml/badge.svg)](https://github.com/adamgruber/mochawesome/actions/workflows/nodejs.yml)\n\nMochawesome is a custom reporter for use with the Javascript testing framework, [mocha][mocha]. It runs on Node.js and works in conjunction with [mochawesome-report-generator][marge] to generate a standalone HTML/CSS report to help visualize your test runs.\n\n## Features\n\n<img align=\"right\" src=\"./docs/marge-report-1.0.1.png\" alt=\"Mochawesome Report\" width=\"55%\" />\n\n- Simple, clean, and modern design\n- Beautiful charts (via ChartJS)\n- Support for test and suite nesting\n- Displays before and after hooks\n- Review test code inline\n- Stack trace for failed tests\n- Support for adding context information to tests\n- Filters to display only the tests you want\n- Responsive and mobile-friendly\n- Offline viewing\n- Supports `parallel` mode\n\n## Requirements\n\n- **Node.js** >= 18\n- **Mocha** 8 – 12 (a peer dependency — install it alongside mochawesome)\n\n## Usage\n\n1. Add Mochawesome to your project:\n\n```bash\nnpm install --save-dev mochawesome\n```\n\n2. Tell mocha to use the Mochawesome reporter:\n\n```bash\nmocha testfile.js --reporter mochawesome\n```\n\n3. If using mocha programatically:\n\n```js\n// Mocha 12 exports a named `Mocha`; earlier versions export it directly.\nconst { Mocha } = require('mocha'); // Mocha <= 11: const Mocha = require('mocha')\n\nconst mocha = new Mocha({\n  reporter: 'mochawesome',\n});\n```\n\n### Parallel Mode\n\nSince `mocha@8` test files can be run in parallel using the `--parallel` flag. In order for mochawesome to work properly it needs to be registered as a hook.\n\n```bash\nmocha tests --reporter mochawesome --require mochawesome/register\n```\n\n### Output\n\nMochawesome generates the following inside your project directory:\n\n```\nmochawesome-report/\n├── assets\n│   ├── app.css\n│   ├── app.js\n│   ├── MaterialIcons-Regular.woff\n│   ├── MaterialIcons-Regular.woff2\n│   ├── roboto-light-webfont.woff\n│   ├── roboto-light-webfont.woff2\n│   ├── roboto-medium-webfont.woff\n│   ├── roboto-medium-webfont.woff2\n│   ├── roboto-regular-webfont.woff\n│   └── roboto-regular-webfont.woff2\n├── mochawesome.html\n└── mochawesome.json\n```\n\nThe two main files to be aware of are:\n\n**mochawesome.html** - The rendered report file\n\n**mochawesome.json** - The raw json output used to render the report\n\n### Options\n\nOptions can be passed to the reporter in two ways.\n\n#### Environment variables\n\nThe reporter will try to read environment variables that begin with `MOCHAWESOME_`.\n\n```bash\n$ export MOCHAWESOME_REPORTFILENAME=customReportFilename\n```\n\n_Note that environment variables must be in uppercase._\n\n#### Mocha reporter-options\n\nYou can pass comma-separated options to the reporter via mocha's `--reporter-options` flag. Options passed this way will take precedence over environment variables.\n\n```bash\n$ mocha test.js --reporter mochawesome --reporter-options reportDir=customReportDir,reportFilename=customReportFilename\n```\n\nAlternately, `reporter-options` can be passed in programatically:\n\n```js\nconst mocha = new Mocha({\n  reporter: 'mochawesome',\n  reporterOptions: {\n    reportFilename: 'customReportFilename',\n    quiet: true,\n  },\n});\n```\n\n#### Available Options\n\nThe options below are specific to the reporter. For a list of all available options see [mochawesome-report-generator options][marge-options].\n\n| Option Name       | Type    | Default     | Description                                                                                                                       |\n| :---------------- | :------ | :---------- | :-------------------------------------------------------------------------------------------------------------------------------- |\n| `quiet`           | boolean | false       | Silence console messages                                                                                                          |\n| `reportFilename`  | string  | mochawesome | Filename of saved report (html and json) <br> _See [notes](#reportfilename-replacement-tokens) for available token replacements._ |\n| `html`            | boolean | true        | Save the HTML output for the test run                                                                                             |\n| `json`            | boolean | true        | Save the JSON output for the test run                                                                                             |\n| `consoleReporter` | string  | spec        | Name of mocha reporter to use for console output, or `none` to disable console report output entirely                             |\n\n#### reportFilename replacement tokens\n\nUsing the following tokens it is possible to dynamically alter the filename of the generated report.\n\n- **[name]** will be replaced with the spec filename when possible.\n- **[status]** will be replaced with the status (pass/fail) of the test run.\n- **[datetime]** will be replaced with a timestamp. The format can be - specified using the `timestamp` option.\n\nFor example, given the spec `cypress/integration/sample.spec.js` and the following config:\n\n```\n{\n  reporter: \"mochawesome\",\n  reporterOptions: {\n    reportFilename: \"[status]_[datetime]-[name]-report\",\n    timestamp: \"longDate\"\n  }\n}\n```\n\nThe resulting report file will be named `pass_February_23_2022-sample-report.html`\n\n**Note:** The `[name]` replacement only occurs when mocha is running one spec file per process and outputting a separate report for each spec. The most common use-case is with Cypress.\n\n### Adding Test Context\n\nMochawesome ships with an `addContext` helper method that can be used to associate additional information with a test. This information will then be displayed inside the report.\n\n**Please note: arrow functions will not work with `addContext`.** See the [example](#example).\n\n### `addContext(testObj, context)`\n\n| param   | type           | description                         |\n| :------ | :------------- | :---------------------------------- |\n| testObj | object         | The test object                     |\n| context | string\\|object | The context to be added to the test |\n\n**Context as a string**\n\nSimple strings will be displayed as is. If you pass a URL, the reporter will attempt to turn it into a link. If the URL links to an image or video, it will be shown inline.\n\n**Context as an object**\n\nContext passed as an object must adhere to the following shape:\n\n```js\n{\n  title: 'some title'; // must be a string\n  value: {\n  } // can be anything\n}\n```\n\n#### Example\n\nBe sure to use ES5 functions and not ES6 arrow functions when using `addContext` to ensure `this` references the test object.\n\n```js\nconst addContext = require('mochawesome/addContext');\n\ndescribe('test suite', function () {\n  it('should add context', function () {\n    // context can be a simple string\n    addContext(this, 'simple string');\n\n    // context can be a url and the report will create a link\n    addContext(this, 'http://www.url.com/pathname');\n\n    // context can be an image url and the report will show it inline\n    addContext(this, 'http://www.url.com/screenshot-maybe.jpg');\n\n    // context can be an object with title and value properties\n    addContext(this, {\n      title: 'expected output',\n      value: {\n        a: 1,\n        b: '2',\n        c: 'd',\n      },\n    });\n  });\n});\n```\n\nIt is also possible to use `addContext` from within a `beforeEach` or `afterEach` test hook.\n\n```js\ndescribe('test suite', () => {\n  beforeEach(function () {\n    addContext(this, 'some context');\n  });\n\n  afterEach(function () {\n    addContext(this, {\n      title: 'afterEach context',\n      value: { a: 1 },\n    });\n  });\n\n  it('should display with beforeEach and afterEach context', () => {\n    // assert something\n  });\n});\n```\n\n## Typescript\n\nThis project does not maintain its own type definitions, however they are available on npm from [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mochawesome).\n\n```bash\nnpm install --save-dev @types/mochawesome\n```\n\n## Related\n\n[mochawesome-report-generator][marge]\n\n## License\n\nmochawesome is [MIT licensed][license].\n\n[mocha]: https://mochajs.org/\n[marge]: https://github.com/adamgruber/mochawesome-report-generator\n[marge-options]: https://github.com/adamgruber/mochawesome-report-generator#options\n[changelog]: CHANGELOG.md\n[license]: LICENSE.md\n","publish_time":1785417310748,"_cnpm_publish_time":1785417310748,"dist-tags":{"latest":"8.1.1","next":"4.0.0-alpha.2"}}