Socket
Book a DemoInstallSign in
Socket

apb-mocha-reporter

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apb-mocha-reporter

A simple dashboard to report mocha test runs.

latest
Source
npmnpm
Version
1.0.7
Version published
Maintainers
1
Created
Source

APB Mocha Reporter

Description

A zero-dependency tool that displays your unit test results in a nifty HTML page.

  • Show live test results in your office / HQ
  • HTML dashboard Auto refreshes every minute
  • Output detailed test results to JSON

Note: This package requires the Node fs module. It does not work in the browser.

Screenshot

Installation

Obviously, you need an existing mocha test suite

  • NPM: npm install apb-mocha-reporter --save-dev
  • Update your test script: mocha ./**.test.js --reporter apb-mocha-reporter

Usage

This reporter replaces the default Mocha console output with a more minimal console output.

The html dashboard is generated each time you run Mocha and is written to:

/yourProject/apb-mocha-reporter-report/apb-mocha-reporter.html

Just open up the html file in a browser, and it will auto-refresh every 60 seconds.

Prevent console output

Pass the silent reporter option to prevent the runner from printing to the console.

mocha ./**.test.js --reporter apb-mocha-reporter --reporter-options silent"

Save detailed test results as JSON

Pass the savejson reporter option to save a detailed report as JSON.

EG:

mocha ./**.test.js --reporter apb-mocha-reporter --reporter-options savejson"

An optional filename may be passed. Otherwise, the output will be in:

yourProject/apb-mocha-reporter-report/apb-mocha-reporter-YYYYMMDD-HHMMSS.json

You may want to pass a file name to prevent logs from building up.

EG:

mocha ./**.test.js --reporter apb-mocha-reporter --reporter-options savejson=filename.json"

Change output directory

Pass the outputdir reporter option with a value to change the output directory.

mocha ./**.test.js --reporter apb-mocha-reporter --reporter-options outputdir='customOutputDir'

Multiple options

To pass multiple options, for example, to be both silent and to save json, reporter-options should be in a comma separated list without spaces.

EG:

mocha ./**.test.js --reporter apb-mocha-reporter --reporter-options silent,savejson=filename.json"

Modifying the template

If you want to fiddle around with the template, you will find apbmochareporter_TEMPLATE.html in the src directory of this package. The output html dashboard is generated using this template.

I didn't want to bloat the package by adding unnecessary templating dependencies, so it currently uses a potentially fragile (but lightweight!) regex based solution that replaces the strings surrounded by double curly braces (eg. {{string}}).

Contributing

PRs welcome.

Have a look at the github issue tracker for suggested updates.

Keywords

mocha

FAQs

Package last updated on 25 Oct 2018

Did you know?

Socket

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.