Skip to content

Commit

Permalink
test humanReadableUnhandledException flag
Browse files Browse the repository at this point in the history
  • Loading branch information
samzilverberg committed Feb 3, 2015
1 parent bcd8b0d commit 30d89fa
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/humanReadableUnhandledException-test.js
@@ -0,0 +1,41 @@
/*
* custom-pretty-print-test.js: Test function as pretty print option.
*
* (C) 2015 Alberto Pose
* MIT LICENSE
*
*/

var assert = require('assert'),
vows = require('vows'),
winston = require('../lib/winston');

vows.describe('winston/transport/humanReadableUnhandledException').addBatch({
"When humanReadableUnhandledException option is used": {
"with memory transport": {
topic: function () {
var transport = new (winston.transports.Memory)({humanReadableUnhandledException: true});
return this.callback(null, transport);
},
"should log the stack trace in a human readable form": function (_, transport) {
var meta = {
date: 'dummy date',
process: 'dummy',
os: 'dummy',
trace: 'dummy',
stack: ['first line','second line']
};

transport.log('info', 'stack:', meta, function (_, logged) {
assert.ok(logged);
assert.equal(1, transport.writeOutput.length);

var msg = transport.writeOutput[0];
assert.notEqual(-1, msg.indexOf('stack: date=dummy date, process=dummy, os=dummy\n'));
assert.notEqual(-1, msg.indexOf(meta.stack[0] + '\n'));
assert.notEqual(-1, msg.indexOf(',' + meta.stack[1]));
});
}
}
}
}).export(module);

0 comments on commit 30d89fa

Please sign in to comment.