{"_id":"mochawesome-with-mocha","_rev":"1540995","name":"mochawesome-with-mocha","description":"A gorgeous reporter for Mocha.js","dist-tags":{"latest":"8.0.0"},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"time":{"modified":"2026-10-15T09:06:36.000Z","created":"2023-01-03T13:57:23.051Z","8.0.0":"2025-03-14T01:47:41.163Z","7.1.3":"2023-01-03T13:57:23.051Z"},"users":{},"author":{"name":"Adam Gruber"},"repository":{"type":"git","url":"git+https://github.com/node-modules/mochawesome.git"},"versions":{"8.0.0":{"name":"mochawesome-with-mocha","version":"8.0.0","description":"A gorgeous reporter for Mocha.js","scripts":{"lint":"eslint src test*","test":"npm run lint && cross-env NODE_ENV=test nyc mocha --config test/.mocharc.json","test:fn":"mocha test-functional --config test-functional/.mocharc.json","test:par":"mocha test-parallel --parallel --config test-parallel/.mocharc.json","test:prog":"node ./test-programmatic","test:mem":"mocha test-functional/mem-test.js --config test-functional/.mocharc.json","test:ctx":"mocha test-functional/test-context.js --config test-functional/.mocharc.json","tdd":"npm run lint && cross-env NODE_ENV=test nyc mocha --config test/.mocharc.json --watch","ci":"npm run test"},"author":{"name":"Adam Gruber"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/node-modules/mochawesome.git"},"keywords":["mocha","reporter","json","html"],"main":"src/mochawesome.js","nyc":{"include":["src/*.js"],"reporter":["lcov","html","text-summary"],"cache":false,"check-coverage":true,"lines":99,"statements":99,"functions":100,"branches":90},"engines":{"node":">=18.19.0"},"dependencies":{"chalk":"^4.1.2","diff":"^5.0.0","json-stringify-safe":"^5.0.1","lodash.isempty":"^4.4.0","lodash.isfunction":"^3.0.9","lodash.isobject":"^3.0.2","lodash.isstring":"^4.0.1","mocha":"^11.1.0","mochawesome-report-generator":"^6.2.0","strip-ansi":"^6.0.1","uuid":"^8.3.2"},"devDependencies":{"cross-env":"^7.0.3","eslint":"^7.20.0","eslint-config-prettier":"^7.2.0","husky":"^5.0.9","lint-staged":"^10.5.4","nyc":"^15.1.0","prettier":"^2.2.1","proxyquire":"^2.1.0","should":"^13.2.3","sinon":"^9.2.4"},"lint-staged":{"*.js":"eslint --cache --fix","*.{js,css,md}":"prettier --write"},"prettier":{"arrowParens":"avoid","semi":true,"singleQuote":true,"tabWidth":2,"trailingComma":"es5"},"eslintConfig":{"extends":["eslint:recommended","prettier"],"env":{"es6":true,"mocha":true,"node":true},"parserOptions":{"ecmaVersion":9}},"_id":"mochawesome-with-mocha@8.0.0","gitHead":"d478a20051d36c48abdd6c3d60c70b0133be2008","bugs":{"url":"https://github.com/node-modules/mochawesome/issues"},"homepage":"https://github.com/node-modules/mochawesome#readme","_nodeVersion":"20.18.3","_npmVersion":"10.8.2","dist":{"integrity":"sha512-JY9bXUqbEK3ad4UtsvCXtyzxo9UED7c7YdNWshfWuSkSBM9TxVgJUPI7Vcd4P3XWc3RoASe/6zRXNGITxEE03g==","shasum":"297d011abdc528a016f3a7ac48e6134dd6c1e4f4","tarball":"http://registry-npm.ywwl.com/mochawesome-with-mocha/download/mochawesome-with-mocha-8.0.0.tgz","fileCount":11,"unpackedSize":35907,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/mochawesome-with-mocha@8.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDwmRneut23LyKIwL5ZUzm5CWPHj6E3YdAXgSy1bf/Q/wIhALtJO19fpodvv2uDOUZ+repzvFL/8wcRgxvwwsZ7wxOz"}],"size":12158,"noattachment":false,"key":"/mochawesome-with-mocha/-/mochawesome-with-mocha-8.0.0.tgz"},"_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"directories":{},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mochawesome-with-mocha_8.0.0_1741916860953_0.31514083219121103"},"_hasShrinkwrap":false,"publish_time":1741916861163,"_cnpm_publish_time":1741916861163},"7.1.3":{"name":"mochawesome-with-mocha","version":"7.1.3","description":"A gorgeous reporter for Mocha.js","scripts":{"lint":"eslint src test*","test":"npm run lint && cross-env NODE_ENV=test nyc mocha --config test/.mocharc.json","test:fn":"mocha test-functional --config test-functional/.mocharc.json","test:par":"mocha test-parallel --parallel --config test-parallel/.mocharc.json","test:prog":"node ./test-programmatic","test:mem":"mocha test-functional/mem-test.js --config test-functional/.mocharc.json","test:ctx":"mocha test-functional/test-context.js --config test-functional/.mocharc.json","tdd":"npm run lint && cross-env NODE_ENV=test nyc mocha --config test/.mocharc.json --watch","prepack":"npm run test"},"author":{"name":"Adam Gruber"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/node-modules/mochawesome.git"},"keywords":["mocha","reporter","json","html"],"main":"src/mochawesome.js","nyc":{"include":["src/*.js"],"reporter":["lcov","html","text-summary"],"cache":false,"check-coverage":true,"lines":99,"statements":99,"functions":100,"branches":90},"dependencies":{"chalk":"^4.1.2","diff":"^5.0.0","json-stringify-safe":"^5.0.1","lodash.isempty":"^4.4.0","lodash.isfunction":"^3.0.9","lodash.isobject":"^3.0.2","lodash.isstring":"^4.0.1","mocha":"^10.2.0","mochawesome-report-generator":"^6.2.0","strip-ansi":"^6.0.1","uuid":"^8.3.2"},"devDependencies":{"cross-env":"^7.0.3","eslint":"^7.20.0","eslint-config-prettier":"^7.2.0","husky":"^5.0.9","lint-staged":"^10.5.4","nyc":"^15.1.0","prettier":"^2.2.1","proxyquire":"^2.1.0","should":"^13.2.3","sinon":"^9.2.4"},"lint-staged":{"*.js":"eslint --cache --fix","*.{js,css,md}":"prettier --write"},"prettier":{"arrowParens":"avoid","semi":true,"singleQuote":true,"tabWidth":2,"trailingComma":"es5"},"eslintConfig":{"extends":["eslint:recommended","prettier"],"env":{"es6":true,"mocha":true,"node":true},"parserOptions":{"ecmaVersion":9}},"gitHead":"cc030106b4741df17a2ea5ea408fcd25835c5c15","bugs":{"url":"https://github.com/node-modules/mochawesome/issues"},"homepage":"https://github.com/node-modules/mochawesome#readme","_id":"mochawesome-with-mocha@7.1.3","_nodeVersion":"16.18.1","_npmVersion":"8.19.2","dist":{"integrity":"sha512-C7df5V1hy2nvAlX7Z7H2YjvvFPUCyyqaK39JdSTK+owpfiTz2OjhGGpraAMW+DgimGbd3uLPn1RW62Ow5T7ZZw==","shasum":"867c62c114c0681ff7d850d54a95abb2030bd06f","tarball":"http://registry-npm.ywwl.com/mochawesome-with-mocha/download/mochawesome-with-mocha-7.1.3.tgz","fileCount":11,"unpackedSize":35749,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDe0HlCXWL/CO85rG15OeOwruff/fIxHmfrsi3hCBYmqQIgE2uxYBknTZ4ptvSqQcWl2Zgl6VkrDUdpoitzAeL7uh0="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjtDRDACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmop+Q//ZCa0M3XKtrYlbKyTslyosIeIuTnETHnHZNtLKEZmkJAIG9RT\r\nhuVx0tJCtq9yOAFSSfijW7MPbI0D7Hc9MgYQKAAoJGNw5tz6C40j2xPcK61r\r\n9rzR7xQf6kVrVyb/SFKgTIgLVzd/jEk4tyTCp8urQlhHWKdacNKX6E5LN2nI\r\nVapg0kmbPtv4jBT6mt+SNV6cTzdd2zLegT1OAIs39fJ9FhdTx3dLTuk9UgkH\r\n4glZbhisf3jqmYBcp68tdj3yfFIHT0FwgRLGKgj9q2BFFnlYgO54TFigxbhO\r\n1LUcbgfZGTt9fy4+XVrBdiZ0IYn9Ba3msOUUHNYyi3/DHjFGCYeXXQ8qkT+C\r\nltxCk4JBtiAJctozVgR5TEqcREinl6qwqYSvqZ9KZKDkaBa3QGUiNVoSdc7d\r\nmovNN/PAXYe589qop7rENEzF8lzS25gnY+ONGnxx7DPZmJc5R6ik3JuZUrEt\r\nOYmSCdAbGjTAMhwK5a2LNHv9S9mdtwNJSLqa80Mej9W7b5XmOfMYqqgdsKTG\r\nR2T03pYOGWA8OPnqAm58AWbOPJ3DtEuHiGDGKa5Bjr19B+0W+dC/7qOXXoYp\r\n2nHcqt8BYXchgmu/x511vRSyD6pXk5jc1089QK0GsA5zGD9RI4mtL49D2l2K\r\nM4/6oiVxL0EUfn1Lc8/7WLyeYvV/eCE9eCo=\r\n=DNpB\r\n-----END PGP SIGNATURE-----\r\n","size":12098,"noattachment":false,"key":"/mochawesome-with-mocha/-/mochawesome-with-mocha-7.1.3.tgz"},"_npmUser":{"name":"fengmk2","email":"fengmk2@gmail.com"},"directories":{},"maintainers":[{"name":"fengmk2","email":"fengmk2@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mochawesome-with-mocha_7.1.3_1672754242880_0.23578942658199709"},"_hasShrinkwrap":false,"publish_time":1672754243051,"_cnpm_publish_time":1672754243051}},"readme":"# mochawesome-with-mocha\n\n[![npm](https://img.shields.io/npm/v/mochawesome-with-mocha.svg?style=flat-square)](http://www.npmjs.com/package/mochawesome-with-mocha)\n[![Node.js CI](https://github.com/node-modules/mochawesome/actions/workflows/nodejs.yml/badge.svg?branch=master)](https://github.com/node-modules/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 (>=10) and works in conjunction with [mochawesome-report-generator][marge] to generate a standalone HTML/CSS report to help visualize your test runs.\n\n> Forked [mochawesome](https://github.com/adamgruber/mochawesome) add mocha to dependencies.\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## Usage\n\n1. Add Mochawesome to your project:\n\n`npm install --save-dev mochawesome-with-mocha`\n\n2. Tell mocha to use the Mochawesome reporter:\n\n`mocha testfile.js --reporter mochawesome-with-mocha`\n\n3. If using mocha programatically:\n\n```js\nvar mocha = new Mocha({\n  reporter: 'mochawesome-with-mocha',\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`mocha tests --reporter mochawesome-with-mocha --require mochawesome-with-mocha/register`\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-with-mocha --reporter-options reportDir=customReportDir,reportFilename=customReportFilename\n```\n\nAlternately, `reporter-options` can be passed in programatically:\n\n```js\nvar mocha = new Mocha({\n  reporter: 'mochawesome-with-mocha',\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-with-mocha/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```\n$ npm 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[license]: LICENSE.md\n","_attachments":{},"homepage":"https://github.com/node-modules/mochawesome#readme","bugs":{"url":"https://github.com/node-modules/mochawesome/issues"},"license":"MIT"}