【发布时间】:2019-10-25 13:52:13
【问题描述】:
我有一个返回承诺的函数。在我使用 chai 的测试文件中,我希望发生以下情况:
const result = sendSurveyDataToAnalytics(userId,eventType,eventTitle)
result.then(() => {
Logger.info("Succeed in the test if we get here")
}).catch(() => {
Logger.info("Fail in the test if we get here")
});
代码解释了它。然后成功,捕获失败。使用可能期望或应该(已经安装 chai-as-promised)的正确方法是什么
【问题讨论】:
标签: unit-testing promise mocha.js chai chai-as-promised