Skip to content

Commit

Permalink
Errors are now dumped to the firebug console if available (taken from…
Browse files Browse the repository at this point in the history
… QUnit)
  • Loading branch information
choan committed Nov 18, 2008
1 parent b289816 commit a55543e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/test_case.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,13 @@ JsUnitTest.Unit.Testcase.prototype.info = function(message) {

JsUnitTest.Unit.Testcase.prototype.error = function(error, test) {
this.errors++;
this.actions['retry with throw'] = function() { test.run(true) };
this.actions['retry with throw'] = function() { test.run(true); };
this.messages.push(error.name + ": "+ error.message + "(" + JsUnitTest.inspect(error) + ")");
if( typeof console != "undefined" && console.error && console.warn && console.info) {
console.error("Test '" + test.name.replace(/^\s+/), ''.replace(/\s+$/, '') + "' died, exception and test follows");
console.info(error);
console.warn(test.test.toString());
}
};

JsUnitTest.Unit.Testcase.prototype.status = function() {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_case_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ <h1>JavaScript unit test file</h1>

// Error
testError: function() { with(this) {
testcase.error({name: "name", message: "An Error"});
testcase.error({name: "name", message: "An Error"}, this);
assertEqual(0, testcase.assertions, "Assertions");
assertEqual(1, testcase.errors, "Errors");
assertEqual("name: An Error([object Object])", testcase.messages[0], 'Should be equal');
Expand Down

0 comments on commit a55543e

Please sign in to comment.