should.js icon indicating copy to clipboard operation
should.js copied to clipboard

Fix throws `TypeError` when passing an arrow function

Open wmzy opened this issue 6 years ago • 2 comments

Codes like this:

    should.throws(
      () => {
        throw new Error();
      },
      () => true
    );

won't work:

TypeError: Function has non-object prototype 'undefined' in instanceof check

wmzy avatar Sep 30 '19 10:09 wmzy

should.throws follow assert.throws behavior only. Your use case is not supported by assert.throws as i see.

btd avatar Oct 05 '19 11:10 btd

assert.throws support this. See the "Custom error validation" example.

wmzy avatar Oct 08 '19 02:10 wmzy