MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / eventually

Function eventually

talent/test/talent.test.js:30–43  ·  view source on GitHub ↗

* For eventually consistent APIs, retry the test after a few seconds, up to 3 times. * @param {function} testFunction the test function to retry. * @returns {function}

(testFunction)

Source from the content-addressed store, hash-verified

28 * @returns {function}
29 */
30function eventually(testFunction) {
31 return async () => {
32 let delayMs = 2000;
33 for (let i = 0; i < 2; ++i) {
34 try {
35 return await testFunction();
36 } catch (e) {
37 await new Promise(resolve => setTimeout(resolve, delayMs));
38 delayMs *= 2;
39 }
40 }
41 return await testFunction();
42 };
43}
44
45describe('Talent Solution Jobs API v4 samples', () => {
46 const projectId = process.env.GCLOUD_PROJECT;

Callers 1

talent.test.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected