{"record":{"id":"fe1b907fe9e19540","repo":"microsoft/playwright","slug":"mount-requires-baseurl-to-point-at-the-component-gallery-set","errorCode":null,"errorMessage":"mount() requires `baseURL` to point at the component gallery. Set it in your Playwright config.","messagePattern":"mount\\(\\) requires `baseURL` to point at the component gallery\\. Set it in your Playwright config\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/playwright/src/index.ts","lineNumber":519,"sourceCode":"    let [page] = context.pages();\n    if (!page)\n      page = await context.newPage();\n    await use(page);\n  },\n\n  mount: async ({ page, baseURL }, use) => {\n    // exposeFunctions turns any callbacks in props into real, browser-callable\n    // functions that dispatch back to the test.\n    const callMount = (params: { story: string, props?: Record<string, any> }) =>\n      page.evaluate(async p => {\n        const w = window as any;\n        if (typeof w.mount !== 'function')\n          throw new Error('The gallery page does not define window.mount().');\n        await w.mount(p);\n      }, params, { exposeFunctions: true, serialize: ['Map', 'Set'] });\n    await use(async (storyId: string, props?: any) => {\n      if (!baseURL)\n        throw new Error('mount() requires `baseURL` to point at the component gallery. Set it in your Playwright config.');\n      // The gallery is a single page (served at baseURL) that exposes window.mount()/window.unmount().\n      await page.goto(baseURL);\n      await callMount({ story: storyId, props });\n      // Points at the gallery root, scope the queries: component.getByRole(...).\n      return Object.assign(page.locator('#root'), {\n        // update() re-renders the same story with new props without navigating; if the gallery\n        // reuses its root/instance, the framework reconciles and component state is preserved.\n        update: (newProps?: any) => callMount({ story: storyId, props: newProps }),\n        unmount: () => page.evaluate(async () => {\n          await (window as any).unmount?.();\n        }),\n      });\n    });\n  },\n});\n\ntype ScreenshotOption = PlaywrightWorkerOptions['screenshot'] | undefined;\n","sourceCodeStart":501,"sourceCodeEnd":537,"githubUrl":"https://github.com/microsoft/playwright/blob/f1d33b5029be8bbc1095fe88e559117fa3a6243b/packages/playwright/src/index.ts#L501-L537","documentation":"The mount() fixture requires the baseURL config option to know where the component gallery page is served. If baseURL is not set, the fixture refuses to proceed and throws this error, because there is no gallery page to load the story into.","triggerScenarios":"Using the mount() fixture while the Playwright config lacks use.baseURL (and no CLI/fixture override supplies it).","commonSituations":"Component (gallery) tests added to a project originally configured only for plain e2e tests, config's use.baseURL removed or renamed, or CI running a config file that never sets baseURL.","solutions":["Set baseURL in playwright.config.ts: use: { baseURL: 'http://localhost:<gallery-port>' }.","Start the gallery dev server and point baseURL at it.","Use a project-specific config or CLI/fixture override that supplies the URL when running."],"exampleFix":"// before (playwright.config.ts)\nexport default defineConfig({});\n// after\nexport default defineConfig({ use: { baseURL: 'http://localhost:3000' } });","handlingStrategy":"validation","validationCode":"if (!test.info().project.use.baseURL)\n  throw new Error('Set use.baseURL in playwright.config.ts to the component gallery URL before using mount().');","typeGuard":"function hasBaseURL(use: PlaywrightTestOptions['use']): use is typeof use & { baseURL: string } {\n  return typeof use.baseURL === 'string' && use.baseURL.length > 0;\n}","tryCatchPattern":"try {\n  const component = await mount('my-story');\n} catch (e) {\n  if ((e as Error).message.includes('baseURL')) {\n    console.error('Add to playwright.config.ts: use: { baseURL: \"http://localhost:3000\" }');\n  }\n  throw e;\n}","preventionTips":["Set use.baseURL in the config file, not ad hoc per test.","Keep component (gallery) tests in a dedicated project with its own baseURL.","Add a config schema/lint check requiring baseURL for the component-testing project.","Document the baseURL requirement in the project README for CI setups."],"tags":["config","component-testing","baseurl"],"backgroundTag":"missing-required-config-field","analyzedSha":"f1d33b5029be8bbc1095fe88e559117fa3a6243b","analyzedAt":"2026-09-21T21:58:31.278Z","contentChangedAt":"2026-09-21T21:58:31.278Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}