# shhh

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

Latest version **1.0.3** (published 2016-03-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install shhh
pnpm add shhh
yarn add shhh
bun add shhh
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2016-03-08 |
| First published | 2016-03-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Antti Kupila |
| Maintainers | akupila |
| Keywords | console, node, disable, test, quiet, monkeypatch |

## Links

- npm: https://www.npmjs.com/package/shhh
- Repository: git@github.com:akupila/shhh
- Homepage: https://github.com/akupila/shhh
- Issues: https://github.com/akupila/shhh/issues
- npm.io page: https://npm.io/package/shhh

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2016-03-08
- 1.0.2 — 2016-03-05
- 1.0.1 — 2016-03-05
- 1.0.0 — 2016-03-05

## README

# shhh

[![Coverage Status](https://coveralls.io/repos/github/akupila/shhh/badge.svg?branch=master)](https://coveralls.io/github/akupila/shhh?branch=master)

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](https://github.com/winstonjs/winston)

## Installation

```bash
npm install --save shhh
```

## Usage

```javascript
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

```javascript
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

```javascript
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

```bash
npm run test
```

## Run test coverage

```bash
npm run cover
```

---
_Source: https://npm.io/package/shhh · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
