Skip to content

browser.initPage relative paths from --config are ignored/silently fail #290

@yuvalkarif

Description

@yuvalkarif

Bug description

When using playwright-cli --config <file>, browser.initPage entries with relative paths (for example ./src/initPage.ts) do not run.

The command succeeds, but the init hook is not applied, and there is no visible error.

Reproduction

config.json:

{
  "browser": {
    "initPage": ["./src/initPage.ts"]
  }
}

src/initPage.ts:

export default async ({ page }) => {
  await page.setViewportSize({ width: 50, height: 50 });
};

Run:

playwright-cli --config config.json open https://demo.playwright.dev/todomvc/ --headed
playwright-cli eval "window.innerWidth"

Actual

window.innerWidth remains the default (e.g. 1200), meaning initPage was not applied.

Expected

Relative browser.initPage paths should resolve (to cwd or config file directory), and the hook should run.

Notes

  • Using an absolute path works:
    PLAYWRIGHT_MCP_INIT_PAGE="$(pwd)/src/initPage.ts" playwright-cli open https://demo.playwright.dev/todomvc/ --headed
    Then window.innerWidth is 50.
  • This appears to fail silently (no user-facing error in normal output).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions