Socket
Socket
Sign inDemoInstall

console-mock2

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

console-mock2

Mocks console output for Node.js unit tests by wrapping a block and returning the output as an array.


Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

console-mock2

NPM version Linux macOS Windows compatible

Build status Coverage status Dependency status Renovate enabled

Open in Gitpod

Mocks console output for Node.js unit tests by wrapping a block and returning the output as an array.

Install

# NPM
$ npm install console-mock2

# Yarn
$ yarn add console-mock2

Usage

const consoleMock = require('console-mock2');

function someVerboseFunction(param) {
  console.log('foo');
  console.log('bar');
  return 5;
}

var output = [];
var result = consoleMock(() => someVerboseFunction(param), output);
// output = ['foo']
// result = 5

consoleMock(() => {
  someVerboseFunction(param);
  ...
});

consoleMock(new Promise((resolve, reject) => {
  setTimeout(() => {
    console.log('foo');
    resolve();
  });
});

License

Unless stated otherwise all works are:

Copyright © Sebastian Landwehr info@dword-design.de

and licensed under:

MIT License

Keywords

FAQs

Package last updated on 18 Feb 2020

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