How to test async function with Sinon JS?
问题 Below is a minimal example of what I want to achieve: I want to test fn3() being called if the async function fn2() resolved (when calling fn1 ). But I somehow failed to do that with sinon 's stub syntax. I would like to know what I misunderstood. // System Under Test export function fn1() { fn2().then(() => { fn3(); }); } export async function fn2() { return new Promise((resolve, reject) => { // expensive work resolve(); }); } export function fn3() { console.log("fn3"); } // Test import * as