MCPcopy Create free account
hub / github.com/Snapchat/Valdi / eventuallyOk

Function eventuallyOk

valdi/vscode_debugger/src/test/testIntegrationUtils.ts:85–102  ·  view source on GitHub ↗
(
  fn: () => Promise<T> | T,
  timeout = 1000,
  wait = 10,
)

Source from the content-addressed store, hash-verified

83export const itIntegrates = itIntegratesBasic;
84
85export const eventuallyOk = async <T>(
86 fn: () => Promise<T> | T,
87 timeout = 1000,
88 wait = 10,
89): Promise<T> => {
90 const deadline = Date.now() + timeout;
91 while (true) {
92 try {
93 return await fn();
94 } catch (e) {
95 if (Date.now() + wait > deadline) {
96 throw e;
97 }
98
99 await delay(wait);
100 }
101 }
102};
103
104afterEach(async () => {
105 await del([`${forceForwardSlashes(testFixturesDir)}/**`], {

Callers 4

profiling.test.tsFile · 0.90
pickTerminationFunction · 0.90
pickAttach.test.tsFile · 0.90

Calls 3

delayFunction · 0.90
nowMethod · 0.65
fnFunction · 0.50

Tested by 1

pickTerminationFunction · 0.72