Generates summary reports of all the suites executed in a single Mocha execution. This reporter also works when run in --parallel mode.
https://cdtester.github.io/mocha-summary-report/summary-report.html
Provides a summary for each suite and a total summary of all the suites in the terminal console.
This report can be turned off via the report options.
Provides a summary of all the suites in a text file. This text file can be added to an email.
This report can be turned off via the report options.
Provides a summary of when and where the suites were executed, a summary of all the suites and a summary of each test (including the test steps) in a HTML file.
The HTML report has a responsive web design to match most screen sizes.
This Section provides information about the overall details about when and where the tests were executed.

This sub section provides information about the:
Versionof the project release that is being tested. This information comes from process.env variable, this can be set in the CI server parameters or added to npm_config_ varaibles either in your npmrc file or as a custom option on the execution line. The location can be configured in the report options.- Test
Cyclethat this test executed as part of. Similar to Version, this is configurable. - Test
Environmentthat this test executed as part of. Similar to Version, this is configurable. Tagsfound in all the tests that were executed. Duplicate tags are removed. The tag should be placed in your test file on the Mocha Describe feature. Tags can be useful to denote what type of test (e.g. smoke, regression etc) and/or the feature of the project. The tag prefix can be configured in the reporter options.
This sub section provides information about the:
Run Dateof the test execution.Start Timeof the the first test execution.End Timeof the last test execution.Durationof the total test executions.
This section can show some limited information about the CI/CD server the test was executed on. A custom set of functions have been created based on env-ci package, this is due to that package uses import to load modules and I could not get it to work with the mocha-multi-reporters which uses require to load modules. This version of the package works with the following CI servers:
- Azure Devops
- Bitbucket
- CircleCI
- GitHub Actions
- GitLab CI
- Jenkins
- TeamCity
- Travis
If the tests are run on a local machine, then the sub section heading will indicate this.

This section provides an overall status of how many tests:
Runin totalPassed, a test that has all steps passed.Skipped, a test that was not executed.Failed, a test that has one or more failed step.
This section also provides metrics for:
Passed Rateof tests executed, whch uses the formula(passed tests / total executed tests) * 100.Tests/stests executed per second, which uses the formula(passed tests + failed tests) / total execution time in seconds. This metric can be used to comapre against manual test execution rates.
This section provides an overall status of how many test steps:
Runin totalPassed, a test step that has a passed status.Skipped, a test step that was not executed.Failed, a test step that has a failed status.
This section also provides metrics for:
Passed Rateof test steps executed, whch uses the formula(passed test steps / total executed Test steps) * 100.Steps/ssteps executed per second, which uses the formula(passed test steps + failed test steps) / total execution time in seconds. This metric can be used to comapre against manual test execution rates.
If you use other test reports like Mochawesome, you will need to use a reporter like mocha-multi-reporters. This is how the Suites section is presented when no other reports are used during the Mocha test execution.
This is how the Suites section is presented when other reports are used during the Mocha test execution. A link button becomes available that opens the other report in a new browser tab.
This report can be turned off via the report options.
This section Provides detais of each test suite, including:
- The
Test ID. This should be a unique code that can identify your test on your test management tool. In this example, Zephyr tests are located on Jira and will have a Jira issue key. The test ID should be placed on the Mocha Describe feature where tags are detailed. The Test ID prefix can be configured in the reporter options. Also, the Test ID can be a link to your manual test. The url is configured in the reporter options, this will be the url base that precedes theTest ID. Tagsassociated to the test. The tag should be placed in your test file on the Mocha Describe feature. Tags can be useful to denote what type of test (e.g. smoke, regression etc) and/or the feature of the project. The tag prefix can be configured in the reporter options.Test Scenario title. The tags at test ID are stripped from the title.Passed / Skipped / FailedHow many steps in the tests Passed, skipped or failed.- The
Durationof the test suite in seconds.
Each test suite can be expanded to reveal more details about the test steps status by clicking on the + icon in the Expand column. This new section shows the test step:
StepNumber.Step description.Errormessage that was produced if the test step failed.Retriesthe number of retries performed, not the max number of retries (unless the max limit was reached).Status.Durationin seconds. This duration includes the duration of each retry.
Add mocha-summary-report to your project by adding it to to your package.json:
"dependencies": {
"mocha-summary-report": "github:CDTester/mocha-summary-report"
},
Then install it with:
npm i
Usage examples can be found on github mocha-summary-report.
You can set up the reporter in a mocharc file and running the test with
mocha --config .mocharc.js
Where the mocharc file has the following options:
reporter: 'mocha-summary-report',
'reporter-option': [
'environmentVar=testenv',
'projectName=project_name',
'projectVersion=project_version',
'projectCycle=npm_test_cycle',
'manualTestLink=manual_test_url',
'output=test_report',
'testIDPrefix=$',
'tagPrefix=@',
'consoleSummary=true',
'textFileSummary=true',
'htmlSummary=true',
'passRateGreen=80',
'passRateAmber=70'
],This option can be used when using mocha-multi-reporters.
mocha --config .mocharc.js
Where the mocharc file has the following options:
reporter: 'mocha-summary-report',
'reporter-option': ['configFile=./config/default.json'],And the config file has the following options:
{
"reporterEnabled": "mocha-summary-report,mochawesome",
"mochawesomeReporterOptions": {
"reportDir": "test_report",
"reportFilename": "test-report.html"
},
"mochaSummaryReportReporterOptions": {
"environmentVar": "testenv",
"projectName": "project_name",
"projectVersion": "project_version",
"projectCycle": "test_cycle",
"manualTestLink": "manual_test_url",
"output": "test_report",
"testIDPrefix": "$",
"tagPrefix": "@",
"consoleSummary": "true",
"textFileSummary": "true",
"htmlSummary": "true",
"passRateGreen": 80,
"passRateAmber": 70,
"otherReportLink": "test_report/test-report.html",
"includeMochaBase": false
}
}The summary reports can be configured in the reporter options:
| Option Name | Type | Default | Description |
|---|---|---|---|
consoleSummary |
boolean | true | option to turn off the summary in the console log by setting to false. |
textFileSummary |
boolean | true | option to turn off the summary in a text file by setting to false. |
htmlSummary |
boolean | true | option to turn off the summary in a text file by setting to false. |
projectName |
string | '--' | process.env variable name that denotes the name of the project. |
projectVersion |
string | '--' | process.env variable name that denotes the version of the project being tested. |
projectCycle |
string | '--' | process.env variable name that denotes the test cycle name of the test execution. |
environmentVar |
string | '--' | process.env variable name that denotes the test environment. |
tagPrefix |
string | '@' | Prefix to be used to capture tags used in the tests. |
testIDPrefix |
string | '$' | Prefix to be used to capture the test ID used in the tests. |
passRateGreen |
string | '90' | Value used to determine the background colour of the overall success rate of which is deemed acceptable. |
passRateAmber |
string | '50' | Value used to determine the background colour of the overall success rate of which is deemed a warning. |
output |
string | 'test_report' | Folder location to be used to save summary report to. |
otherReportLink |
string | undefined | File location of any other reports created at the end of the test execution. |
includeMochaBase |
true | option to turn off the Mocha Base reporter in the console. Mocha-multi-reporters includes Base reporting which duplicates this reporters output. | |
manualTestLink |
string | undefined | process.env variable name that contains the base URL of your test management application. The testIDPrefix value is suffixed to this URL to create the full link. |
The process.env variables can be set up in many ways:
- as a command line to running your tests e.g.
npm run test [spec] --project=ProjectName. (these will be set up with a prefix ofnpm_config_project. The 'npm_config_project' is the value that needs to be saved in the reporter option forprojectName. ) - in an .npmrc file (these will be set up with a prefix of
npm_config_) - from your CI application.







