Skip to content

Commit

Permalink
[v0.6 fix] Properly inspect errors
Browse files Browse the repository at this point in the history
This is related and blocked by cloudhead/eyes.js#12.

Gist of what's going on: `Error` properties are non-enumerable in `node
v0.6`, so `Object.keys` which is being used in `eyes.js` won't list them
(we need to use `Object.getOwnPropertyNames`). This results in errors
being outputted as `{}`, for example in `assert.isNull(err)` statement.
  • Loading branch information
mmalecki authored and indexzero committed Nov 25, 2011
1 parent 6760a2e commit 8788a52
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/assert/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@ require('assert').AssertionError.prototype.toString = function () {
}

function parse(str) {
return str.replace(/{actual}/g, inspect(that.actual)).
var actual = inspect(that.actual, {showHidden: that.actual instanceof Error}),
expected;

if (that.expected instanceof Function) {
expected = that.expected.name;
}
else {
expected = inspect(that.expected, {showHidden: that.actual instanceof Error});
}

return str.replace(/{actual}/g, actual).
replace(/{operator}/g, stylize(that.operator, 'bold')).
replace(/{expected}/g, (that.expected instanceof Function)
? that.expected.name
: inspect(that.expected));
replace(/{expected}/g, expected);
}

if (this.message) {
Expand Down

0 comments on commit 8788a52

Please sign in to comment.