std-mocks
Mock node stdout and stderr without pain.
Last updated 3 years ago by neoziro .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install std-mocks 
SYNC missed versions from official npm registry.

std-mocks

Build Status Dependency Status devDependency Status

Mock node stdout and stderr without pain.

Install

npm install std-mocks

Usage

var stdMocks = require('std-mocks');

stdMocks.use();
process.stdout.write('ok');
console.log('log test\n');
stdMocks.restore();

var output = stdMocks.flush();
console.log(output.stdout); // ['ok', 'log test\n']

stdMocks.use([options])

Start mocking std output, by default both are mocked.

Options:

@param {object} [options] Options
@param {boolean} [options.stdout=true] Mock stdout
@param {boolean} [options.stderr=true] Mock stderr
@param {boolean} [options.print=false] Also print to std

stdMocks.restore([options])

Restore std output, by default both are restored.

Options:

@param {object} [options] Options
@param {boolean} [options.stdout=true] Mock stdout
@param {boolean} [options.stderr=true] Mock stderr

stdMocks.flush([options])

Flush collected data, by default both are collected.

Options:

@param {object} [options] Options
@param {boolean} [options.stdout=true] Mock stdout
@param {boolean} [options.stderr=true] Mock stderr
@returns {object} Object containing two array corresponding to outputs.

License

MIT

Current Tags

  • 1.0.1                                ...           latest (3 years ago)

2 Versions

  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 2
This Week 6
This Month 10
Last Day 2
Last Week 2
Last Month 19
Dependencies (1)
Dev Dependencies (2)

Copyright 2014 - 2016 © taobao.org |