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-emailable

v1.1.1

Published

A single page emailable reporter for Mocha.js

Downloads

375

Readme

mocha-emailable

Generates test results in the a single page emailable HTML. Cloned from mochawesome, this is pretty much a clone with the exception of generating a single page HTML report instead of merged json file.

Usage

  1. Add to your project:

npm install --save-dev mocha-emailable

  1. Tell mocha to use the mocha-emailable reporter:

mocha testfile.js --reporter mocha-emailable

  1. If using programatically:
var mocha = new Mocha({
  reporter: 'mocha-emailable',
});

Parallel Mode

Since mocha@8 test files can be run in parallel using the --parallel flag. In order for mocha-emailable to work properly it needs to be registered as a hook.

mocha tests --reporter mocha-emailable --require mocha-emailable/register

The two main files to be aware of are:

result.html - The rendered report file

result.json - The raw json output used to render the report

Custom variable

Custom variable can be included in the result html by creating mocha-emailable.properties file in the project root. Additionally, environment variable can also be used in real time.

// Set environment variable
export BASE_URL=http://www.test.com

// Properties file
NAME=Test
BASE_URL=${BASE_URL}

Options

Options can be passed to the reporter in two ways.

Mocha reporter-options

You can pass comma-separated options to the reporter via mocha's --reporter-options flag. Options passed this way will take precedence over environment variables.

mocha test.js --reporter mocha-emailable --reporter-options reportDir=customReportDir,reportFilename=customReportFilename

Alternately, reporter-options can be passed in programatically:

var mocha = new Mocha({
  reporter: 'mocha-emailable',
  reporterOptions: {
    reportFilename: 'customReportFilename',
    reportDir: './here',
  },
});

addContext(testObj, context)

| param | type | description | | :------ | :------------- | :---------------------------------- | | testObj | object | The test object | | context | string | The context to be added to the test |

Example

Be sure to use ES5 functions and not ES6 arrow functions when using addContext to ensure this references the test object.

import * as addContext from 'mocha-emailable/addContext';

describe('test suite', function () {
  it('should add context', function () {
    // context can be a simple string
    addContext(this, 'simple string');
  });
});

License

mocha-emailable is MIT licensed.