【发布时间】:2018-08-25 17:59:20
【问题描述】:
我需要测试一系列异步函数是否按特定顺序调用。有没有简单的方法可以做到这一点?
下面是我想要实现的示例:
describe("Test ASYNC order", () => {
it("Calls in a particular order", () => {
const p1 = new Promise(resolve => setTimeout(resolve, 500));
const p2 = new Promise(resolve => setTimeout(resolve, 600));
const p3 = new Promise(resolve => setTimeout(resolve, 200));
/* How would I test that the order of the promises resolving is p3 then p1 then p2 ????? */
})
})
【问题讨论】:
标签: javascript node.js testing promise jestjs