npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mocha-spectreport-reporter

v1.5.3

Published

A mocha reporter for use with Spectreport

Downloads

5,286

Readme

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 |