{"__v":0,"_id":"57f18fd64cb25a0e00b26615","category":{"__v":16,"_id":"56954a95fe18811700c9bfdf","pages":["56954a97fe18811700c9c01d","56954a97fe18811700c9c01e","56954a97fe18811700c9c01f","56954a97fe18811700c9c020","56954a97fe18811700c9c021","56954a97fe18811700c9c022","56954a97fe18811700c9c023","56954a97fe18811700c9c024","56954a97fe18811700c9c025","56954a97fe18811700c9c026","56954a97fe18811700c9c027","56954a97fe18811700c9c028","56954a97fe18811700c9c029","5696cda524490c3700170a05","5697efe61c4dc8230054268e","5697efe72cf4060d004eaa75","56993ff47465970d00650b8f","56a7a155dfdabc0d000ae910","56a7a155b5d0920d0051cd81","56a7a1a6cf6d771700baeee3","56a7a1a63d33bc2100793d5d","56a7a23097e8b00d0096d209","56a7a230ea3e3417000df4b1","56a7a25acf6d771700baeee6","56a7a25a03f28c0d00a545bf","56a7a2b83d33bc2100793d60","56a7a2b8b5d0920d0051cd82","56b27fe42db51f0d0044e566"],"project":"568fde81b700ce0d002f4b43","version":"56954a94fe18811700c9bfda","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-01-09T16:40:53.584Z","from_sync":false,"order":4,"slug":"guides","title":"Guides"},"parentDoc":null,"project":"568fde81b700ce0d002f4b43","user":"568fffce769f210d0013258f","version":{"__v":6,"_id":"56954a94fe18811700c9bfda","project":"568fde81b700ce0d002f4b43","createdAt":"2016-01-12T18:48:52.007Z","releaseDate":"2016-01-12T18:48:52.007Z","categories":["56954a95fe18811700c9bfdb","56954a95fe18811700c9bfdc","56954a95fe18811700c9bfdd","56954a95fe18811700c9bfde","56954a95fe18811700c9bfdf","56954a95fe18811700c9bfe0","56954a95fe18811700c9bfe1","56954a95fe18811700c9bfe2","56954a95fe18811700c9bfe3","56954a95fe18811700c9bfe4","5695649fdcaf0d1700cb8721","5696c1168560a60d00e2c1d6","56a7a32e79395317007c1ad6","5898fc3eec49fb0f004c2663","589cc675ea37da23004e05e1"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"foo","version_clean":"0.0.0","version":"0.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-10-02T22:53:10.510Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"auth":"required","params":[],"url":""},"isReference":false,"order":12,"body":"# Contents\n\n- :fa-angle-right: [Reporters](#section-reporters)\n- :fa-angle-right: [Supported Reporters](#section-supported-reporters)\n- :fa-angle-right: [Custom Reporters](#section-custom-reporters)\n  - [Local Reporters](#section-local-reporters)\n  - [npm Reporters](#section-npm-reporters)\n- :fa-angle-right: [Reporter Options](#section-reporter-options)\n\n# Reporters\n\nWhen running Cypress headlessly or in CI, you can specify which Mocha reporter Cypress uses through your `cypress.json` or via the command line:\n\n`cypress.json`:\n\n[block:code]\n{\n    \"codes\": [\n        {\n            \"code\": \"{\\n  \\\"reporter\\\": \\\"nyan\\\"\\n}\\n\",\n            \"language\": \"javascript\"\n        }\n    ]\n}\n[/block]\n\nCommand line:\n\n[block:code]\n{\n    \"codes\": [\n        {\n            \"code\": \"cypress run --reporter json\\n\",\n            \"language\": \"shell\"\n        }\n    ]\n}\n[/block]\n\n***\n\n# Supported Reporters\n\nCypress supports the following reporters:\n\n* [Mocha's built-in reporters](https://mochajs.org/#reporters).\n* [`teamcity`](https://github.com/cypress-io/mocha-teamcity-reporter)\n* [`junit`](https://github.com/michaelleeallen/mocha-junit-reporter)\n* Custom reporters ([see below](#section-custom-reporters))\n\n***\n\n# Custom Reporters\n\nCypress supports custom reporters, whether local to your project or installed through npm.\n\n## Local Reporters\n\nSay you have the following directory structure:\n\n[block:code]\n{\n    \"codes\": [\n        {\n            \"code\": \"> my-project\\n  > cypress\\n  > src\\n  > reporters\\n    - custom.js\\n\",\n            \"language\": \"txt\"\n        }\n    ]\n}\n[/block]\n\nSpecify the path to your custom reporter to use it:\n\n`cypress.json`:\n\n[block:code]\n{\n    \"codes\": [\n        {\n            \"code\": \"{\\n  \\\"reporter\\\": \\\"reporters/custom.js\\\"\\n}\\n\",\n            \"language\": \"javascript\"\n        }\n    ]\n}\n[/block]\n\nCommand line:\n\n[block:code]\n{\n    \"codes\": [\n        {\n            \"code\": \"cypress run --reporter reporters/custom.js\\n\",\n            \"language\": \"shell\"\n        }\n    ]\n}\n[/block]\n\n***\n\n## npm Reporters\n\nIf you have installed a custom reporter through npm, specify the package name:\n\n[block:code]\n{\n    \"codes\": [\n        {\n            \"code\": \"// cypress.json\\n{\\n  \\\"reporter\\\": \\\"mochawesome\\\"\\n}\\n\",\n            \"language\": \"javascript\"\n        }\n    ]\n}\n[/block]\n\nCommand line:\n\n[block:code]\n{\n    \"codes\": [\n        {\n            \"code\": \"cypress run --reporter mochawesome\\n\",\n            \"language\": \"shell\"\n        }\n    ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Peer Dependencies\",\n  \"body\": \"You need to install any peer dependencies the reporter requires, even if they're bundled with Cypress. For example, [mochawesome](https://github.com/adamgruber/mochawesome) requires `mocha` as a peer dependency. You will need to install mocha as a dev dependency of your own project for it to work (`npm install mocha --save-dev`).\"\n}\n[/block]\n\n***\n\n# Reporter Options\n\nSome reporters accept options to customize their behavior. These can be specified in your `cypress.json` or via the command line:\n\n\n[block:code]\n{\n    \"codes\": [\n        {\n            \"code\": \"// cypress.json\\n{\\n  \\\"reporter\\\": \\\"junit\\\",\\n  \\\"reporterOptions\\\": {\\n    \\\"mochaFile\\\": \\\"results/my-test-output.xml\\\",\\n    \\\"toConsole\\\": true\\n  }\\n}\\n\",\n            \"language\": \"javascript\"\n        }\n    ]\n}\n[/block]\n\nCommand line:\n\n[block:code]\n{\n    \"codes\": [\n        {\n            \"code\": \"cypress run --reporter junit --reporter-options \\\"mochaFile=results/my-test-output.xml,toConsole=true\\\"\\n\",\n            \"language\": \"shell\"\n        }\n    ]\n}\n[/block]\n\nReporter options differ depending on the reporter (and may not be supported at all). Refer to the documentation for the reporter you are using for details on which options are supported.","excerpt":"Customize test results with reporters","slug":"reporters","type":"basic","title":"Reporters"}

Reporters

Customize test results with reporters

# Contents - :fa-angle-right: [Reporters](#section-reporters) - :fa-angle-right: [Supported Reporters](#section-supported-reporters) - :fa-angle-right: [Custom Reporters](#section-custom-reporters) - [Local Reporters](#section-local-reporters) - [npm Reporters](#section-npm-reporters) - :fa-angle-right: [Reporter Options](#section-reporter-options) # Reporters When running Cypress headlessly or in CI, you can specify which Mocha reporter Cypress uses through your `cypress.json` or via the command line: `cypress.json`: [block:code] { "codes": [ { "code": "{\n \"reporter\": \"nyan\"\n}\n", "language": "javascript" } ] } [/block] Command line: [block:code] { "codes": [ { "code": "cypress run --reporter json\n", "language": "shell" } ] } [/block] *** # Supported Reporters Cypress supports the following reporters: * [Mocha's built-in reporters](https://mochajs.org/#reporters). * [`teamcity`](https://github.com/cypress-io/mocha-teamcity-reporter) * [`junit`](https://github.com/michaelleeallen/mocha-junit-reporter) * Custom reporters ([see below](#section-custom-reporters)) *** # Custom Reporters Cypress supports custom reporters, whether local to your project or installed through npm. ## Local Reporters Say you have the following directory structure: [block:code] { "codes": [ { "code": "> my-project\n > cypress\n > src\n > reporters\n - custom.js\n", "language": "txt" } ] } [/block] Specify the path to your custom reporter to use it: `cypress.json`: [block:code] { "codes": [ { "code": "{\n \"reporter\": \"reporters/custom.js\"\n}\n", "language": "javascript" } ] } [/block] Command line: [block:code] { "codes": [ { "code": "cypress run --reporter reporters/custom.js\n", "language": "shell" } ] } [/block] *** ## npm Reporters If you have installed a custom reporter through npm, specify the package name: [block:code] { "codes": [ { "code": "// cypress.json\n{\n \"reporter\": \"mochawesome\"\n}\n", "language": "javascript" } ] } [/block] Command line: [block:code] { "codes": [ { "code": "cypress run --reporter mochawesome\n", "language": "shell" } ] } [/block] [block:callout] { "type": "info", "title": "Peer Dependencies", "body": "You need to install any peer dependencies the reporter requires, even if they're bundled with Cypress. For example, [mochawesome](https://github.com/adamgruber/mochawesome) requires `mocha` as a peer dependency. You will need to install mocha as a dev dependency of your own project for it to work (`npm install mocha --save-dev`)." } [/block] *** # Reporter Options Some reporters accept options to customize their behavior. These can be specified in your `cypress.json` or via the command line: [block:code] { "codes": [ { "code": "// cypress.json\n{\n \"reporter\": \"junit\",\n \"reporterOptions\": {\n \"mochaFile\": \"results/my-test-output.xml\",\n \"toConsole\": true\n }\n}\n", "language": "javascript" } ] } [/block] Command line: [block:code] { "codes": [ { "code": "cypress run --reporter junit --reporter-options \"mochaFile=results/my-test-output.xml,toConsole=true\"\n", "language": "shell" } ] } [/block] Reporter options differ depending on the reporter (and may not be supported at all). Refer to the documentation for the reporter you are using for details on which options are supported.