Created
August 13, 2014 14:55
-
-
Save leobalter/b1fe1f7b34f37a809e2d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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