export function enableHealthyCheck(
baseToExtend: TestType<PlaywrightTestArgs & PlaywrightTestOptions, PlaywrightWorkerArgs & PlaywrightWorkerOptions>
) {
return baseToExtend.extend<{}, {healthyCheck: void, baseURL: string}>({
healthyCheck: [async ({browser, baseURL}, use, workerInfo) => {
console.log('healthyCheck', baseURL)
const page = await browser.newPage();
try {
// await retry(async() => {
// await new LoginPage(page).navigateTo();
// }, (10 * 60) / 5);
} catch (e) {
// throw new Error(`${baseURL} is not healthy. Unable to proceed with testing.`);
} finally {
await page.close();
}
await use();
}, { scope: 'worker', auto: true, timeout: 15 * 60 * 1000 }],
});
}
current error:
worker fixture "healthyCheck" cannot depend on a test fixture "baseURL" defined in node_modules/playwright/lib/index.js:920:24.
It seems i'll have to move this to globalsetup if no one can provide a solution.
This thread is trying to answer question "How to get access to baseURL from a worker fixture with auto set to true?"
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].