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
const wait = ms => new Promise(r => setTimeout(() => r(), ms)); | |
const fetchPosts = (context, event) => { | |
const { q: num } = context; | |
console.log('> fetchPosts',num) | |
if (num == 5) { | |
return new Promise((r, reject) => reject(new Error('Oh too bad...'))); | |
} |
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
const wait = ms => new Promise(r => setTimeout(() => r(), ms)) | |
const fetchResource = async ({ url, fakeDelayMs = 0 }) => { | |
await wait(fakeDelayMs) | |
return fetch(url).then(res => res.json()) | |
} | |
const constants = { | |
MAX_QUESTION_SCORE: 3, | |
MAX_RETRIES: 15, | |
FAILURE_DELAY: 2000, |
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
// The Door - state machine | |
const fetchMachine = Machine({ | |
id: 'TheDoor', | |
initial: 'locked', | |
context: {}, | |
states: { | |
locked:{ | |
id:'locked', | |
on: { UNLOCK: 'unlocked' } | |
}, |
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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
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
type Config = { | |
logPerformance?: boolean; | |
timeout?: number; // Timeout in milliseconds | |
}; | |
function createTestRunner(initialConfig?: Config) { | |
let globalConfig: Config = { | |
logPerformance: false, | |
timeout: 5000, | |
...initialConfig, |
OlderNewer