Skip to content

Commit

Permalink
Fix mocha timeout issue
Browse files Browse the repository at this point in the history
Added a timeout to the 'after all' hook, as it is possible this can take longer than two seconds.

Also made the callbacks into 'it' regular functions instead of arrow functions for consistency with the 'after all' hook.
 * With arrow functions, the 'this' binding for 'this.timeout' does not point to the desired target, and the 'after' hook threw an error if I tried to use the original approach I had with the 'it' blocks.
  • Loading branch information
biancadanforth committed Aug 19, 2019
1 parent 68b791b commit 8d87435
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions test/functional/isVisible.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ describe('isVisible', () => {
);
}

it('should return false when an element is hidden', async () => {
it('should return false when an element is hidden', async function () {
this.timeout(WAIT_MS);
const hiddenElementIds = await driver.executeScript(`
return [].slice.call(document.querySelectorAll('[id^="not-visible-"]')).map((element) => element.id);
`);
Expand All @@ -41,10 +42,12 @@ describe('isVisible', () => {

for (const id of hiddenElementIds) {
await checkVisibility(id, false);

}
}).timeout(60000);
});

it('should return true when an element is visible', async () => {
it('should return true when an element is visible', async function () {
this.timeout(WAIT_MS);
const visibleElementIds = await driver.executeScript(`
return [].slice.call(document.querySelectorAll('[id^="visible-"]')).map((element) => element.id);
`);
Expand All @@ -53,7 +56,10 @@ describe('isVisible', () => {
for (const id of visibleElementIds) {
await checkVisibility(id, true);
}
}).timeout(60000);
});

after(async () => driver.quit());
after(async function () {
this.timeout(WAIT_MS);
return driver.quit();
});
});

0 comments on commit 8d87435

Please sign in to comment.