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

@ppwcode/mocha-ssst

v1.0.0

Published

A Mocha reporter that hides what is written to `console` during tests, unless a test fails.

Downloads

93

Readme

mocha-ssst

A Mocha reporter that hides what is written to console during tests, unless a test fails.

Installation

npm install -D @ppwcode/mocha-ssst

In package.json:

{
  "...": "…",
  "mocha": {
    "...": "…",
    "reporter": ["@ppwcode/mocha-ssst"]
  },
  "....": "…"
}

Why

There are ample reasons to use console.log(…) in production code, e.g., to easily use the structured logging provided by AWS Lambdas. And even if you don’t do that, some of your dependencies might.

Furthermore, we like to console.log(…) progress, results, and intermediate results in our Mocha test code. It gives a warm confidence while developing, e.g., using WebStorm. The Jetbrains reporter shows these logs in a nice, isolated way. And these logs help enormously when something goes wrong later, in CI. Obviously, this is not ment to replace automated validation of your results.

We like the Mocha Spec reporter a lot. It gives us a clear view of what is happening, and how the tests progress. The other reporters, to us, are less informative.

But if you combine these 2, the output of production code and test code console.log(…) calls is immediate, and messes up the report.

What

This reporter alleviates that. It behaves like the Mocha Spec reporter, but console.log(…) outputs are buffered.

Logs are only shown when the test fails, or when the DEBUG environment variable is set, and are shown below the test title.

DEBUG=true npm run test

Test errors are presented in a readable way, and it doesn’t crash when test errors contain circular data structures.

Optionally, you may also add the following at the entrypoint of your test suite (it needs to be placed before any other Mocha-related calls):

require('mocha-reporter').hook()

This will add an extra line containing the file name and line number of the test upon error.

Where

The npm package is at https://www.npmjs.com/package/@ppwcode/mocha-ssst.

The code is maintained in a Bitbucket repository.

Bug reports and other feedback should be directed at the repository’s issue management system at Bitbucket.

License

MIT

Fork

This started out as a fork of Wizcorp/mocha-reporter.

Wizcorp/mocha-reporter is unmaintaned. The last commit is d.d. 2017-12-13. That version contains an annoying bug that results in false positive tests in cases where the error contains circular data structures.

After some years without response, and since this is still our favorite reporter, this fork was created to fix the bug ourselves. The code has changed much. It is cleaned, modernized, and now the reporter has tests with 100% coverage.