UNPKG

1.12 kBMarkdownView Raw
1stdout-stderr
2=============
3
4mock stdout and stderr
5
6[![Version](https://img.shields.io/npm/v/stdout-stderr.svg)](https://npmjs.org/package/stdout-stderr)
7[![Known Vulnerabilities](https://snyk.io/test/npm/stdout-stderr/badge.svg)](https://snyk.io/test/npm/stdout-stderr)
8[![Downloads/week](https://img.shields.io/npm/dw/stdout-stderr.svg)](https://npmjs.org/package/stdout-stderr)
9[![License](https://img.shields.io/npm/l/stdout-stderr.svg)](https://github.com/jdxcode/stdout-stderr/blob/master/package.json)
10
11**Usage:**
12
13```js
14const {stdout, stderr} = require('stdout-stderr')
15
16stdout.start() // start mocking stdout
17console.log('writing to stdout') // this will not be displayed
18stdout.stop() // stop mocking stdout
19assert(stdout.output === 'writing to stdout') // view the output
20
21
22/* options */
23stdout.stripColor = false // disable automatic ansi code stripping
24stdout.print = true // also output to screen
25```
26
27This uses the [debug](https://npm.im/debug) module so you can also see the output by setting `DEBUG=stdout|stderr|*`.