Pretty output messages to stdout/stderr with no extra dependencies.
Install the module with: npm install simple-output
var log = require('simple-output');
log.success('Successful hello world');
This module helps on testing your output data by making it simpler to mock simple-output
and its methods or use the exposed streams interface to which the data gets written to.
In order to test your output information, replace the stdout/stderr properties with an mock object containing a write function (simulating the streams api). See the example below:
var log = require('simple-output');
var myModule = require('../my-module');
log.stdout = {
write: function(msg) {
assert(msg, 'hello world');
}
};
myModule.methodThatUsesSimpleLogInfoInternally();
var requireInject = require('require-inject');
var myModule = requireInject('../my-module', {
'simple-output': {
info: msg => assert(msg, 'hello world');
}
});
myModule.methodThatUsesSimpleLogInfoInternally();
MIT © 2022 Ruy Adorno