首页 > 解决方案 > 我如何使用 mocha chai 为这个功能编写测试。我一直在尝试做 expect(notification(app).to.equal(url, messageBody)

问题描述

const notification = async(app) => {
it does some for loop on app
await fetch (url, messageBody);
}

messageBody is an object
messageBody = {
method: 'POST',
body: {
name: 'User1',
text: 'hello'
},
headers: {
'Content-type': 'application/json'
}
};

我一直在尝试做expect(notification(app).to.equal(url,messageBody)。我得到assertionError预期未定义等于(url,messageBody)。

标签: javascriptunit-testingasync-awaitmocha.jschai

解决方案


推荐阅读