gruntjs / grunt-contrib-nodeunit

Run Nodeunit unit tests.
http://gruntjs.com/
MIT License
70 stars 27 forks source link

"Error:" doesn't display correctly falsy "actual" or "expected" values. #12

Closed cowboy closed 11 years ago

cowboy commented 11 years ago

Right now when an assertion like this fails:

test.ok(undefined, 'this value should be truthy');

We see this:

>> my test
>> Message: this value should be truthy
>> Error: this value should be truthy

But we should really see this:

>> my test
>> Message: this value should be truthy
>> Error: undefined == true

I think the fix is to change this line inside betterErrors:

if (!e || !e.actual || !e.expected) { return assertion; }

To this:

if (!e || !('actual' in e) || !('expected' in e)) { return assertion; }