最有帮助的是:How to write a test which expects an Error to be thrown in Jasmine? 这是我在读完上面的帖子后的问题。我正在单元测试一个抛出错误的方法。我想捕获错误,这样我就知道单元测试是成功的。下面是我的函数调用: expect(function(){instance.selectMember(event);}).toThrow(); 和生成错误的代码行: throw我也尝
我预计403禁止错误。下面的代码打印catch块中的错误,并使相同的调用不会抛出错误。为什么?response = await api(`verify/${profile.auth.verifyToken}`, {method: 'POST'}).json();Received function did not throw 此变体也不起作用: expect(() => api(`verify