我正在使用下面的测试用例来测试 Mocha 和 Chai 中的服务,它工作正常。
describe('Google ', () => {
it('POST: Google.', async () => {
const results = await readGoogle.execute(jmsPayload);
console.log(`Final Result : ${results.toString()}`);
});
});
对于上述代码,我需要处理一种情况。实际上我有时会从服务类 readGoogle.execute 方法中得到这个异常。
TypeError: Cannot read property 'status' of undefined
这是从 readGoogle.execute 方法的角度来看的。但我的要求是我需要通过上述测试用例,即使我从 readGoogle.execute await 方法中得到错误。
1)我无权访问 readGoogle.execute 方法,所以我无法处理那里的未定义检查。仅在我的测试用例中要做的任何事情。
2)我return true,在上面尝试过,'it'但测试用例仍然失败。
3)我也试过了,断言(真);在上面it,但测试用例仍然失败。
任何人都可以向我建议一些我可以始终通过上述 test_case 的想法(即使在成功和失败的情况下)?
提前致谢。
摇曳的蔷薇
相关分类