tj / should.js

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

should.throw doesn't stop exceptions from printing out #41

Closed juriejan closed 12 years ago

juriejan commented 12 years ago

I'm using 'should.throw' in the current fashion:

app
  .get('/')
  .end(function (res) {
    done();
  }).should.throw('fail');

This catches the exception and passes the test, but the exception still prints out to the console. This doesn't seem right to me. Am I missing something here?

serby commented 12 years ago

I added the string matching function to should.throw() and didn't experience the exceptions outputted to console.

If you run the tests

 make test

Do you still see the exceptions on the console?

If they are not, can you put together a test case that exposes the bug:

https://github.com/visionmedia/should.js/blob/master/test/should.test.js#L496

Many thanks

juriejan commented 12 years ago

After trying to setup a test case I see that the output doesn't print out in the usual cases.

I'm currently trying to write some tests for Connect (https://github.com/senchalabs/connect) and specifically trying to catch a 403 error coming from a test application. It's only when I try to do this type of thing that it still prints out the error. I see though that all the other tests in Connect also still print out their response exceptions, so I guess it's not that bad.

What do you think?

serby commented 12 years ago

I'm not a expert on connect but I do know that AssertionErrors are explicitly outputted:

https://github.com/senchalabs/connect/blob/1.x/lib/http.js#L209

This may be what is causing your problem. I don't think it is a mocha issue.

juriejan commented 12 years ago

That's probably it. Thanks. Just carrying on with things as they are for the time being.