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

前端 未结 7 1936
傲寒
傲寒 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:06

    And if you are already using ES6/ES2015 then you can also use an arrow function. It is basically the same as using a normal anonymous function but shorter.

    expect(() => model.get('z')).to.throw('Property does not exist in model schema.');
    

提交回复
热议问题