This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// scenarioRunner.js | |
async function scenarioRunner(scenarioIds, runScenario) { | |
try { | |
await Promise.all(scenarioIds.map(runScenario)); | |
} catch (error) { | |
console.log("A scenario failed", error); | |
} | |
} | |
// scenarioRunner.spec.js | |
function mockRunScenario(scenarioId) { | |
return new Promise((resolve, reject) => { | |
if (scenarioId === 1) { | |
console.log("scenario fail", scenarioId); | |
reject(scenarioId); // warning | |
} | |
setTimeout(() => { | |
console.log("scenario success", scenarioId); | |
resolve(); | |
}, (10 - scenarioId) * 10); | |
}); | |
} | |
scenarioRunner([0, 1, 2], mockRunScenario); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment