How to write a test which expects an Error to be thrown in Jasmine?

前端 未结 9 1078
忘了有多久
忘了有多久 2020-11-28 17:26

I\'m trying to write a test for the Jasmine Test Framework which expects an error. At the moment I\'m using a Jasmine Node.js integration from GitHub.

In my Node mod

9条回答
  •  自闭症患者
    2020-11-28 18:20

    In my case the function throwing error was async so I followed here:

    await expectAsync(asyncFunction()).toBeRejected();
    await expectAsync(asyncFunction()).toBeRejectedWithError(...);
    

提交回复
热议问题