tj / should.js

BDD style assertions for node.js -- test framework agnostic
MIT License
2.75k stars 195 forks source link

`should.fail` doesn't set message property #12

Closed aseemk closed 11 years ago

aseemk commented 13 years ago

This is really a bug/quirk in the native assert module, but we could patch it in should.

try {
    should.fail('hello world');
} catch (err) {
    should.exist(err.message);    // fails
    console.log(err);
}

If you comment out the should.exist, the console log gets:

{ name: 'AssertionError',
  message: undefined,
  actual: 'hello world',
  expected: undefined,
  operator: undefined,
  stack: [Getter/Setter] }

So if you actually want to use the message, right now you have to do:

should.fail(null, null, 'hello world');

What do you think about patching fail to accept just a message?

aseemk commented 13 years ago

Fixed this as part of my message support: #13