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
global.waitFor = (expectationFunction) => { | |
const MAX_WAIT = 5000; | |
const POLL_INTERVAL = 100; | |
return new Promise((resolve, reject) => { | |
const startTime = Date.now(); | |
let error; | |
const interval = setInterval(() => { | |
try { | |
if (Date.now() - startTime < MAX_WAIT) { | |
expectationFunction(); |