tj / should.js

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

Cannot test exception throwed by constructor #211

Closed gywbd closed 10 years ago

gywbd commented 10 years ago

if i throw an error in a constructor, the should.throw() doesn't work.

function Constructor() { throw new Error('fail'); }

(new Constructor()).should.throw() cannot pass.

btd commented 10 years ago

Yes, that is expected. Because new Constructor() will return object, but .throw() expect a function.

(function() { new Constructor() }).should.throw()