Mocha / Chai expect.to.throw not catching thrown errors

前端 未结 7 1946
傲寒
傲寒 2020-11-22 07:20

I\'m having issues getting Chai\'s expect.to.throw to work in a test for my node.js app. The test keeps failing on the thrown error, but If I wrap the test case

7条回答
  •  深忆病人
    2020-11-22 08:11

    As this answer says, you can also just wrap your code in an anonymous function like this:

    expect(function(){
        model.get('z');
    }).to.throw('Property does not exist in model schema.');
    

提交回复
热议问题