Last active
March 7, 2022 13:58
-
-
Save aymericbouzy/eb71f4bc790a055f4dabc8c7ee16b9cc to your computer and use it in GitHub Desktop.
This file contains hidden or 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