【发布时间】:2020-03-16 10:54:28
【问题描述】:
我正在尝试测试我的代码(Typescript),它应该在没有传递参数时抛出
getID(ID) { if(!ID){throw new Error('stop js')} ....}
it('should fail if no ID', async () => {
expect(async () => await myService.getID() ).to.throw("stop js");
})
根据文档,上面应该可以工作,但是当我运行测试时,我得到了
1) myTest
should fail if no groupId is passed:
AssertionError: expected [Function] to throw an error
【问题讨论】:
-
你试过
expect(async () => await myService.getID() ).to.eventually.throw("stop js");吗? -
TypeError: [Function] 不是 thenable。这就是我得到的
标签: javascript typescript unit-testing testing chai