mocha-spectreport-reporter
A mocha reporter for use with Spectreport
Last updated 4 years ago by jj4th .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install mocha-spectreport-reporter 
SYNC missed versions from official npm registry.

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:

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

Current Tags

  • 1.5.3                                ...           latest (4 years ago)

21 Versions

  • 1.5.3                                ...           4 years ago
  • 1.5.2                                ...           4 years ago
  • 1.1.1                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 1.5.0                                ...           4 years ago
  • 1.4.6                                ...           4 years ago
  • 1.4.4                                ...           4 years ago
  • 1.4.3                                ...           4 years ago
  • 1.4.1                                ...           4 years ago
  • 1.4.0                                ...           4 years ago
  • 1.3.0                                ...           4 years ago
  • 1.2.3                                ...           4 years ago
  • 1.2.2                                ...           4 years ago
  • 1.2.1                                ...           4 years ago
  • 1.2.0                                ...           4 years ago
  • 1.0.10                                ...           4 years ago
  • 1.0.6                                ...           5 years ago
  • 1.0.5                                ...           5 years ago
  • 1.0.4                                ...           5 years ago
  • 1.0.3                                ...           5 years ago
  • 1.0.2                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 21
Last Day 0
Last Week 21
Last Month 0
Dependencies (3)
Dev Dependencies (31)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |