mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix(curriculum): retrying tests with delay for async challenges (#55503)
This commit is contained in:
+13
-1
@@ -17,7 +17,19 @@ Add a paragraph element with the `class` `"bio"`, then interpolate `bio` inside
|
||||
You should create a `p` element.
|
||||
|
||||
```js
|
||||
assert.exists(document.querySelector('p'));
|
||||
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('p'), "'p' element not found");
|
||||
```
|
||||
|
||||
Your `p` element should have the class `"bio"`
|
||||
|
||||
+13
-1
@@ -16,7 +16,19 @@ Add an anchor element with the `class` `"author-link"`, interpolate `url` as the
|
||||
You should create an anchor element.
|
||||
|
||||
```js
|
||||
assert.exists(document.querySelector('a'));
|
||||
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('a'), "'a' element not found");
|
||||
```
|
||||
|
||||
Your anchor element should have the class `"author-link"`.
|
||||
|
||||
+13
-1
@@ -16,7 +16,19 @@ Add a `div` element above the author's bio and give it the `class` `"purple-divi
|
||||
You should create a `div` element before your `p` element.
|
||||
|
||||
```js
|
||||
assert.equal(document.querySelector('p')?.previousElementSibling?.tagName, 'DIV');
|
||||
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('p')?.previousElementSibling?.tagName === 'DIV', "'div' element not found");
|
||||
```
|
||||
|
||||
Your `div` element should have the `class` set to `"purple-divider"`.
|
||||
|
||||
Reference in New Issue
Block a user