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

winston-testified-console

v0.0.2

Published

Configures Winston’s Console transport to send all log messages to stderr to keep test output clean

Downloads

5

Readme

winston-testified-console

Configures Winston’s Console transport to send all log messages to stderr to keep test output clean.

Introduction

Good logging is an invaluable mechanism for many software projects, especially those intended to run as local or network services. And increasingly, as technologies like Docker gain in popularity, those messages are commonly sent to the console, rather than to some file.

Automated testing suites are another invaluable mechanism of modern software projects.

But when your software logs to the console, the "noise" from its messages can make your test output difficult to read—particularly if you develop with a watch set up that automatically runs your tests each time you modify one of your source files.

But if you could get all your logging messages to write to stderr, you'd be able to enjoy clean test output by running the tests with a command like this:

# capture log messages to a file
$ npm test 2>./messages.log

# discard log messages entirely
$ npm test 2>/dev/null

And that's what I've designed this package to do for your project's tests. (That is, assuming your project uses Winston for its logging. 😉)

Getting Started

First off, this is , you'll naturally want to add the package to your project:

$ npm i --save-dev winston-testified-console

Assuming your project's test suite already has a "bootstrap" script (if not, and you don't know how to set this up, see here), add the following line amongst its require statements:

require('winston-testified-console')();

And run your tests, sending stderr to /dev/null:

$ env NODE_ENV=testing npm test 2>/dev/null

That was easy, right? At least in theory; your project will likely require a bit more work to get set up, so let's take it from the top.

Configuring Testify

The more complex your project is, the likelier you'll need to do a bit of configuring. The winston-testified-console supports two optional arguments:

  • target, which references what to "testify" console output for. This can be a winston.Logger instance, a winston.Container instance, an array of instance of either type (can be uniform or a mix), and the winston instance itself (default value).

  • isTesting, which is a callback that should return true whenever console output ought to be "testified". The default callback evaulates to true when the NODE_ENV environment variable matches /^test/ (e.g., test, tests, testing, etc).

require('winston-testified-console')(logger, isTestingCb);