MCPcopy
hub / github.com/kubeflow/pipelines / flushPromises

Method flushPromises

frontend/src/TestUtils.ts:37–53  ·  view source on GitHub ↗

* Flushes all already queued promises and returns a promise. Note this will * only work if the promises have already been queued, so it cannot be used to * wait on a promise that hasn't been dispatched yet.

()

Source from the content-addressed store, hash-verified

35 * wait on a promise that hasn't been dispatched yet.
36 */
37 public static async flushPromises(): Promise<void> {
38 const testApi = getTestApi();
39 if (
40 typeof testApi.isMockFunction === 'function' &&
41 testApi.isMockFunction(setTimeout) &&
42 typeof testApi.advanceTimersByTime === 'function'
43 ) {
44 // Fake timers won't advance unless we flush them explicitly.
45 testApi.advanceTimersByTime(0);
46 await Promise.resolve();
47 testApi.advanceTimersByTime(0);
48 await Promise.resolve();
49 return;
50 }
51 await new Promise(resolve => setTimeout(resolve, 0));
52 await new Promise(resolve => setTimeout(resolve, 0));
53 }
54
55 /**
56 * Adds a one-time mock implementation to the provided spy that mimics an error

Calls 1

getTestApiFunction · 0.85

Tested by 15

flushPromisesAndIntervalFunction · 0.64
renderPipelineListFunction · 0.64
waitForPipelinesLoadFunction · 0.64
waitForVersionsLoadFunction · 0.64
renderExperimentDetailsFunction · 0.64
renderNewPipelineVersionFunction · 0.64
renderRunListFunction · 0.64
waitForRunListLoadFunction · 0.64
waitForRunMaskLoadFunction · 0.64
callLoadRunsFunction · 0.64
renderNewRunElementFunction · 0.64