如何测试参数化方法是否抛出 chai 和 mocha?

How to test if parameterized method throws chai and mocha?

我有这个(简化的)代码要测试:

function verifyArg(x) {
  if (x == 400) throw new Error("Bad Parameter!")
}

如何测试 mocha 和 chai 是否正确抛出错误?

我自己找到了答案:

describe("verify()", function() {
   it("throws on 400", function() {
      expect(function() {
         verify(400);
      }).not.to.throw();
   });
});

回调地狱!