Commit 8f7edc9f authored by Daniel Shumway's avatar Daniel Shumway

test: deprecate reporter test

parent 628e3a83
......@@ -4,4 +4,3 @@ require('./tape/test.js');
require('./tape/assertions.js');
require('./tape/callback.js');
require('./tape/recursion.js');
require('./tape/reporter.js');
/*
* DEFAULT REPORTER
*----------------------------------------
* A limited test of the default reporter (only deals with node side of things)
*
* - temporarily suppresses output while supporter is running (console.log will not work)
* - these tests don't go super in-depth, because honestly there's not a ton of risk here.
*/
var tape = require('tape');
var Distilled = require('Distilled');
var reporter = Distilled.REPORTERS.dot;
var output;
function mock (setup, callback) {
return function (t) {
output = ''; //Mock
var write = process.stdout.write;
process.stdout.write = function (message) {
output = output + message;
};
var processCode = process.exitCode;
setup.call(this, t);
process.stdout.write = write; //Unmock
callback.call(this, t);
process.exitCode = processCode; //Final unmock
};
};
tape('Root test', mock(function () {
var test = {};
reporter.call(test, test);
}, function (t) {
t.plan(1);
t.equal(output, '\nTests finished: passed\n', 'Root test is skipped');
}));
tape('Passed test', mock(function () {
var test = {
status : Distilled.STATUS.PASSED,
parent : {},
};
reporter.call(test, test);
}, function (t) {
t.plan(1);
t.equal(output, '.', 'Passed tests are logged as `.`');
}));
tape('Failed test', mock(function () {
var test = {
status : Distilled.STATUS.FAILED,
label : 'child',
error : {
expected : 'expected',
actual : 'actual',
stack : 'stack'
},
parent : {
label : 'parent',
parent : {}
}
};
reporter.call(test, test);
}, function (t) {
t.plan(2);
t.equal(output,
'X\n\n(parent)(child) failed!\nExpected: expected\nActual: actual\nstack\n\n',
'Failed tests write the full error');
t.equal(process.exitCode, 1, 'Failed tests set `process.exitCode` to 1');
}));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment