New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

shhh

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shhh

Allows temporarily disabling console in node.js. Useful for noisy unit tests

  • 1.0.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

shhh

Coverage Status

Allows temporarily disabling console output, for instance when used with noisy unit tests.

While you can disable logging in production with this it's recommend to use a library specifically designed for that purpose. For instance for node check out Winston

Installation

npm install --save shhh

Usage

const shhh = require('shhh');

console.log('This is visible');
shhh.enable();
console.log('This is hidden');
console.error('This is hidden too');
console.time('timer');
console.timeEnd('timer'); // nothing shows up here either
shhh.disable();
console.info('This is visible again');

Usage in mocha tests

dummyMath.js

module.exports.add = function(val1, val2) {
  console.log('Doing some math..');
  console.log('Adding ' + val1 + ' + ' + val2);
  const result = val1 + val2;
  console.log('Result is ' + result);
  return result;
}

test.js

const shhh = require('shhh');
const dummyMath = require('./dummyMath');

describe('Some noisy module', function() {
  before(function() {
    console.log('Starting tests');       // printed to console
    shhh.enable();
    console.log('Tests about to run..'); // not printed to console
  });

  after(function() {
    console.log('Tests finished');       // not printed to console
    shhh.disable();
    console.log('done');                 // printed to console
  });

  it('should do stuff without console being annoying', function() {
    // The function is very noisy but that stuff won't show up in test output
    const result = dummyMath.add(1, 1);
    // No assertion library for simplicity
    if (result !== 2) {
      throw new Error('1 + 1 should be 2');
    }
  });
})

Tests

npm run test

Run test coverage

npm run cover

Keywords

FAQs

Package last updated on 08 Mar 2016

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc