Skip to content

Commit

Permalink
refactor(e2e): simplify waitForExtensions function by removing unnece…
Browse files Browse the repository at this point in the history
…ssary whitespace and improving readability
  • Loading branch information
nelitow committed Nov 22, 2024
1 parent 004716f commit 37f3dad
Showing 1 changed file with 0 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,23 @@ export async function waitForExtensions(
if (!extensions || typeof extensions !== 'object') {
throw new Error('Invalid extensions object provided.');
}

console.log(`Checking extensions (Attempt ${attempt + 1}/${maxAttempts})...`);
const pages = context.pages();

if (!pages.length) {
console.warn('No pages found in the context. Retrying...');
}

const phantomPage = pages.find((page) =>
page.url().includes(extensions.phantom?.id),
);

if (phantomPage) {
console.log('Phantom extension is ready!');
return true;
}

if (attempt >= maxAttempts - 1) {
throw new Error(
`Failed to detect extensions after ${maxAttempts} attempts.`,
);
}

console.log('Phantom extension not found. Retrying in 3 seconds...');
await setTimeout(3000);
return waitForExtensions(context, extensions, maxAttempts, attempt + 1);
Expand Down

0 comments on commit 37f3dad

Please sign in to comment.