Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

mock-debug

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mock-debug

A simple mock for Visionmedia's module 'debug'

latest
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

mock-debug

A simple mock for Visionmedia's module debug.

Examples

var debug = require('debug');  // Visionmedia's debug module
var dlog = debug('label');     // a debug logging function

var makeMockDebug = require('mock-debug');    // A mock module
var mlog = makeMockDebug();                   // a mock debug logging function

dlog('Hello %s', 'world'); // logs to stderr
mlog('Hello %s', 'world'); // logs to an array of strings
mlog(...); // more calls to mlog

var history = mlog.get();  // retrieve the history of log lines
                           // ['Hello world', ...]

Why not override the log function?

In the debug README.md, the section titled stderr vs stdout shows that it is possible to override the log function. This seemingly makes this mock-debug module unnecessary. However, the debug module still applies all of its formatting functions before calling the overridden log function, which is inconvenient if you want to write simple unit test assertions/expectations for the expected log history.

It may be possible to also override the formatting functions, but we prefer the simplicity of this module.

Keywords

debug

FAQs

Package last updated on 21 Aug 2015

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