← Back to Discord Forum

How to get access to baseURL from a worker fixture with auto: true

leblancmenesesposted in #help-playwright
Open in Discord
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?"

4 replies

I don't think you can, baseURL is a test fixture.

I mean two tests could have a different base url, which one your worker fixture should use?


I wasn't able to inject it into scoped worker fixture but page.goto('/') does apply the correct baseURL


changed it to:


Related Discord Threads

AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

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 luc@ray.run.