Test for expected failure in Mocha

后端 未结 9 1969
终归单人心
终归单人心 2020-12-10 01:29

Using Mocha, I am attempting to test whether a constructor throws an error. I haven\'t been able to do this using the expect syntax, so I\'d like to do the following:

<
9条回答
  •  独厮守ぢ
    2020-12-10 02:20

    You can try using Chai's throw construct. For example:

    expect(Constructor).to.throw(Error);
    

提交回复
热议问题