
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
mocha-spectreport-reporter
Advanced tools
A mocha reporter for use with Spectreport. This reporter generates .json test results from a mocha test run in a format understood by the Spectreport HTML report generator. It also has support for console logging (provided by the mocha generic Spec reporter).
If you're testing an Angular web application in Selenium via the Protractor framework, you can enable screenshots. This feature was added as a convenience for the author, and is disabled by default.
The recommended installation method is NPM:
$ npm install mocha-spectreport-reporter --save-dev
You will need to tell mocha to use the reporter:
$ mocha --reporter mocha-spectreport-reporter ... # and other options there
$ mocha -R mocha-spectreport-reporter --reporter-options console=true,screenshots=true,...
If you are using protractor, add the reporter to the mochaOpts
section of your protractor configuration file.
mochaOpts: {
reporter: require('mocha-spectreport-reporter'),
reporterOptions: {
console: true,
screenshot: true
},
ui: 'bdd'
}
Mocha does not currently trap exceptions that occur upon requiring a test file. This means that if you have you have a syntax error, reference error, dependency error, etc... in one of your test files outside of a test function block, mocha will never read the file, and this reporter will have no knowledge of that fact. This is especially relevant projects that use some sort of sharding mechanism, like protractor running with multiple instances of selenium, or against a selenium grid.
As a workaround, there is a contrib script included with this module at: contrib/mocha-loadFiles-patch.js
. This script monkey patches Module._load
and Mocha.prototype.loadFiles
, so it is included only as a workaround.
If you are using a custom interface that does not use Mocha.prototype.loadFiles
this patch will not work.
Simply require this file at some point before running any of your tests, and it will alter mocha to generate failed tests instead of throwing errors. This solution is known to work with Mocha 2.0 and above.
$ mocha -r 'mocha-spectreport-reporter/contrib/mocha-loadFiles-patch'
If you are using protractor, just require the file at the top of your protractor configuration file.
require('mocha-spectreport-reporter/contrib/mocha-loadFiles-patch');
exports.config = { ... }
This reporter supports a few options to customize your usage:
Option | Type | Default | Description |
---|---|---|---|
console | Boolean | False | If set to True, will use the Mocha Spec reporter to output results to the console |
outputDir | String | "test/results" | The directory where the reporter will dump its output |
storyDir | String | "test/stories" | Where the reporter will expect to find your stories, used to represent the directory heirarchy in the results |
screenshot | Boolean | False | If being used with Protractor, this will enable browser screenshots on failed tests |
screenshotDir | String | "test/screenshots" | The directory where screenshots will be stored if True |
FAQs
A mocha reporter for use with Spectreport
The npm package mocha-spectreport-reporter receives a total of 898 weekly downloads. As such, mocha-spectreport-reporter popularity was classified as not popular.
We found that mocha-spectreport-reporter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.