console-mock

1.0.24 • Public • Published

consoleMock

Build Status

Mocked console.log, .info, .table, etc. for node and browsers.

// basic use
var consoleMock = require('console-mock');
var console = consoleMock.create();
console.log(1, 2, 3); // 1 2 3
 
// disabling output
consoleMock.enabled(false); // disables output, but internal history is still written
console.log(3, 2, 1); // does nothing
 
// retrieving history
var history = consoleMock.history();
console.log(history); // does nothing
consoleMock.enabled(true); // enables output
console.log(history); // outputs:
// [ { method: 'log', arguments: [ 1, 2, 3 ] },
//   { method: 'log', arguments: [ 3, 2, 1 ] } ]
 
// clearing history
console.historyClear()
console.log(consoleMock.history()); // outputs: []

Readme

Keywords

none

Package Sidebar

Install

npm i console-mock

Weekly Downloads

9

Version

1.0.24

License

MIT

Last publish

Collaborators

  • andr