Skip to content

Commit 8788a52

Browse files
mmaleckiindexzero
authored andcommitted
[v0.6 fix] Properly inspect errors
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.
1 parent 6760a2e commit 8788a52

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lib/assert/error.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,19 @@ require('assert').AssertionError.prototype.toString = function () {
1010
}
1111

1212
function parse(str) {
13-
return str.replace(/{actual}/g, inspect(that.actual)).
13+
var actual = inspect(that.actual, {showHidden: that.actual instanceof Error}),
14+
expected;
15+
16+
if (that.expected instanceof Function) {
17+
expected = that.expected.name;
18+
}
19+
else {
20+
expected = inspect(that.expected, {showHidden: that.actual instanceof Error});
21+
}
22+
23+
return str.replace(/{actual}/g, actual).
1424
replace(/{operator}/g, stylize(that.operator, 'bold')).
15-
replace(/{expected}/g, (that.expected instanceof Function)
16-
? that.expected.name
17-
: inspect(that.expected));
25+
replace(/{expected}/g, expected);
1826
}
1927

2028
if (this.message) {

0 commit comments

Comments
 (0)