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 🙏

© 2026 – Pkg Stats / Ryan Hefner

mochawesome-screenshots

v2.0.0

Published

A Gorgeous HTML/CSS Reporter for Mocha.js with Screenshot Support

Readme

mochawesome-screenshots

This is a fork of Mochawesome (MochawesomePlusPlus) reporter with added screenshots functionality.

The reporter takes a screenshot after each failed test.

Installation of the module:

$ npm install mochawesome-screenshots --save-dev

Usage remains the same as Mochawesome. Works with both require() (CJS) and import (ESM):

// CommonJS
const Mochawesome = require('mochawesome-screenshots');
const logReport = require('mochawesome-screenshots/logReport');

// ES modules
import Mochawesome from 'mochawesome-screenshots';
import { log, setScreenshot, setReportName } from 'mochawesome-screenshots/logReport';

Requires Node.js >= 20 and Mocha >= 10.

Reporter options

| Option | Description | | --- | --- | | reportDir | Report output directory (default ./mochawesome-reports) | | reportName | Report file name (default mochawesome) | | reportTitle | Report title shown in the navbar | | reportPageTitle | Browser tab title | | takePassedScreenshot | Take screenshots of passed tests too | | clearOldScreenshots | Clear the screenshots folder on start | | shortScrFileNames | Use short screenshot file names | | jsonReport | Also save a .json report | | multiReport | Add a timestamp to the report file name (parallel runs) | | inlineAssets | Embed CSS/JS into the HTML instead of linking | | autoOpen | Open the report in the browser after the run | | screenshotDelay | Delay in ms before the report is written (default 500), lets async screenshot pipelines settle |

Every option can also be set via a MOCHAWESOME_<OPTION> environment variable.

For protractor - configuration file example:

  framework: 'mocha',

  mochaOpts: {
      reporter: 'mochawesome-screenshots',
      reporterOptions: {
          reportDir: 'customReportDir',
          reportName: 'customReportName',
          reportTitle: 'customReportTitle',
          reportPageTitle: 'customReportPageTitle',
          takePassedScreenshot: false,
          clearOldScreenshots: true,
          shortScrFileNames: false,
          jsonReport: false,
          multiReport: false
      },
      timeout: 600000
  },

For playwright and puppeteer:

  • Make global your "page" variable.
  • Add reporterOptions:
framework: playwright (puppeteer)

For cypress:

framework: cypress

For webdriver.io:

framework: webdriverio

For nightwatch.js:

framework: nightwatchjs

Use 'multiReport = true' for parallel test execution (adding timestamp in report file name), or change report name in tests or hooks for shardTestFiles option:

const logReport = require('mochawesome-screenshots/logReport');
    
it('Change report name', function() {
    logReport.setReportName(this, 'customReportName');
});

Log data to report:

const logReport = require('mochawesome-screenshots/logReport');

it('Log build number', function() {
    logReport.log(this, 'build number:' + buildNumber);
});

Add custom screenshots from mochawesome-reports/screenshots folder to report:

it('Custom screenshot', function() {
    ..
    save screenshot 1 to ('./mochawesome-reports/screenshots/'+imageFileName1);
    save screenshot 2 to ('./mochawesome-reports/screenshots/'+imageFileName2);
    ..
    logReport.setScreenshot(this, imageFileName1, 'message1');
    logReport.setScreenshot(this, imageFileName2, 'message2');
});

Development

The reporter runtime is written in strict TypeScript and published as a dual CJS + ESM package. The report client is vanilla JS bundled with esbuild (Chart.js 4 included); styles are LESS on top of Bootstrap 3.

$ npm install          # install dependencies
$ npm run build        # templates -> lib (tsup, CJS+ESM) -> assets (less/esbuild)
$ npm run dev          # watch mode (tsup + templates + less + client)
$ npm test             # build + unit tests (node:test) + smoke tests (mocha + playwright)
$ npm run lint         # eslint (flat config) + tsc --noEmit
$ npm run format       # prettier

Layout:

src/ts/         reporter runtime (TypeScript, strict)
src/js/         report client script (vanilla JS + Chart.js)
src/less/       report styles (LESS + Bootstrap 3)
src/templates/  Handlebars templates (.mu)
scripts/        build scripts (templates, assets, watch)
dist/           build output (published to npm)
e2e/            smoke tests that dogfood the reporter
test/unit/      unit tests (node:test runner)

CI runs lint, build and tests on Node 20/22/24 via GitHub Actions.

Changelog

See changelog.md.