Skip to content

Commit

Permalink
chore: don't use race for final condition
Browse files Browse the repository at this point in the history
  • Loading branch information
jrandolf committed Sep 15, 2022
1 parent fe255bc commit a205f7b
Showing 1 changed file with 8 additions and 24 deletions.
32 changes: 8 additions & 24 deletions test/src/waittask.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,9 +493,7 @@ describe('waittask specs', function () {
await element.evaluate(e => {
e.style.removeProperty('display');
});
await expect(
Promise.race([promise, createTimeout(40)])
).resolves.toBeTruthy();
await expect(promise).resolves.toBeTruthy();
});
it('should wait for element to be visible (visibility)', async () => {
const {page} = getTestState();
Expand All @@ -517,9 +515,7 @@ describe('waittask specs', function () {
await element.evaluate(e => {
e.style.removeProperty('visibility');
});
await expect(
Promise.race([promise, createTimeout(40)])
).resolves.toBeTruthy();
await expect(promise).resolves.toBeTruthy();
});
it('should wait for element to be visible (bounding box)', async () => {
const {page} = getTestState();
Expand Down Expand Up @@ -572,9 +568,7 @@ describe('waittask specs', function () {
// Just peeking
e.style.setProperty('bottom', '99vh');
});
await expect(
Promise.race([promise, createTimeout(40)])
).resolves.toBeTruthy();
await expect(promise).resolves.toBeTruthy();
});
it('should wait for element to be visible recursively', async () => {
const {page} = getTestState();
Expand All @@ -600,9 +594,7 @@ describe('waittask specs', function () {
await element.evaluate(e => {
return e.style.removeProperty('visibility');
});
await expect(
Promise.race([promise, createTimeout(40)])
).resolves.toBeTruthy();
await expect(promise).resolves.toBeTruthy();
});
it('should wait for element to be hidden (visibility)', async () => {
const {page} = getTestState();
Expand All @@ -618,9 +610,7 @@ describe('waittask specs', function () {
await element.evaluate(e => {
return e.style.setProperty('visibility', 'hidden');
});
await expect(
Promise.race([promise, createTimeout(40)])
).resolves.toBeTruthy();
await expect(promise).resolves.toBeTruthy();
});
it('should wait for element to be hidden (display)', async () => {
const {page} = getTestState();
Expand All @@ -636,9 +626,7 @@ describe('waittask specs', function () {
await element.evaluate(e => {
return e.style.setProperty('display', 'none');
});
await expect(
Promise.race([promise, createTimeout(40)])
).resolves.toBeTruthy();
await expect(promise).resolves.toBeTruthy();
});
it('should wait for element to be hidden (bounding box)', async () => {
const {page} = getTestState();
Expand All @@ -654,9 +642,7 @@ describe('waittask specs', function () {
await element.evaluate(e => {
e.style.setProperty('height', '0');
});
await expect(
Promise.race([promise, createTimeout(40)])
).resolves.toBeTruthy();
await expect(promise).resolves.toBeTruthy();
});
it('should wait for element to be hidden (removal)', async () => {
const {page} = getTestState();
Expand All @@ -672,9 +658,7 @@ describe('waittask specs', function () {
await element.evaluate(e => {
e.remove();
});
await expect(
Promise.race([promise, createTimeout(40, true)])
).resolves.toBeFalsy();
await expect(promise).resolves.toBeFalsy();
});
it('should return null if waiting to hide non-existing element', async () => {
const {page} = getTestState();
Expand Down

0 comments on commit a205f7b

Please sign in to comment.