fix(curriculum): retrying tests with delay for async challenges (#55503)

This commit is contained in:
Michael Ehme
2024-08-13 06:13:54 -04:00
committed by GitHub
parent f91b8284bf
commit 7b05b89d03
3 changed files with 39 additions and 3 deletions
@@ -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"`
@@ -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"`.
@@ -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"`.