Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(function() {
/*globals console */
if ( !console || typeof console.log !== "function" ) {
return;
}
var assertionCount = 0,
failed = [];
QUnit.begin(function() {
console.log( "TAP version 13" );
});
QUnit.testStart(function( details ) {
var message = "# ";
message += details.module ? details.module + " - " : "";
console.log( message + details.name );
});
QUnit.log(function( details ) {
var expected, actual,
message = details.message ? " " + details.message : "";
assertionCount++;
if ( details.result ) {
console.log( "ok" + message );
} else {
console.error( "not ok" + message );
if ( details.hasOwnProperty( "expected" ) ) {
expected = QUnit.dump.parse( details.expected );
actual = QUnit.dump.parse( details.actual );
// Weird, but this fixes dumped objects into reporter indentation
expected = expected.replace( /\r|\n/g, "\n " );
actual = actual.replace( /\r|\n/g, "\n " );
console.error(
[
" ---",
" expected: " + expected,
" actual : " + actual,
" ..."
].join( "\n" )
);
}
failed.push( assertionCount );
}
});
QUnit.done(function( details ) {
var perc = ( details.passed * 100 ) / details.total;
perc = perc.toFixed( 2 ) + "% okay";
console.log( "1.." + details.total );
if ( details.failed ) {
console.error( "FAILED tests " + failed.join( ", " ) );
console.error( "Failed " + details.failed + "/" + details.total + "tests, " + perc );
} else {
console.log( perc );
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.