From 11590de34ca3554bf2ff45f3f9dcd0868bc89f53 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Wed, 20 Dec 2023 01:25:57 +0100 Subject: [PATCH] fix: retry async test (#52534) --- .../641da803d9892447d059804e.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da803d9892447d059804e.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da803d9892447d059804e.md index 237e51097fe..4b7cad7706d 100644 --- a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da803d9892447d059804e.md +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da803d9892447d059804e.md @@ -14,7 +14,19 @@ Now create an image tag and give it the `class` `user-img`. Use template interpo You should create an `img` element. ```js -assert.exists(document.querySelector('img')); +const retryingTest = (test, message, tries = 20) => { + if (tries < 1) return Promise.reject(message); + if (test()) return Promise.resolve(); + + return new Promise((resolve, reject) => { + setTimeout(() => { + retryingTest(test, message, tries - 1) + .then(resolve) + .catch(reject); + }, 100); + }); +}; +() => retryingTest(() => document.querySelector('img'), "'img' element not found"); ``` Your `img` element should have the class `user-img`.