Socket
Socket
Sign inDemoInstall

mocha-spectreport-reporter

Package Overview
Dependencies
3
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    mocha-spectreport-reporter

A mocha reporter for use with Spectreport


Version published
Weekly downloads
1.3K
decreased by-2.24%
Maintainers
1
Install size
34.8 MB
Created
Weekly downloads
 

Readme

Source

Build Status Coverage Status devDependency Status

mocha-spectreport-reporter

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).

Special note for Protractor

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.

Installation & Usage

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'
}

Special Note on syntax errors in test files.

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 = { ... }

Options

This reporter supports a few options to customize your usage:

OptionTypeDefaultDescription
consoleBooleanFalseIf set to True, will use the Mocha Spec reporter to output results to the console
outputDirString"test/results"The directory where the reporter will dump its output
storyDirString"test/stories"Where the reporter will expect to find your stories, used to represent the directory heirarchy in the results
screenshotBooleanFalseIf being used with Protractor, this will enable browser screenshots on failed tests
screenshotDirString"test/screenshots"The directory where screenshots will be stored if True

Keywords

FAQs

Last updated on 07 Jul 2016

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc