Node assert.throws not catching exception

前端 未结 4 732
死守一世寂寞
死守一世寂寞 2020-12-15 03:49

Given this code:

var assert = require(\'assert\');

function boom(){
    throw new Error(\'BOOM\');
}

assert.throws( boom(), Error );

I ge

4条回答
  •  生来不讨喜
    2020-12-15 04:21

    This is closely related to the issue people with with other assertion Mocha/Chai. See this answer for the description with node examples:
    Mocha / Chai expect.to.throw not catching thrown errors

提交回复
热议问题