PhoenixTest.Playwright.Config (PhoenixTestPlaywright v0.12.1)

Copy Markdown View Source

Configuration options for the Playwright driver.

Most should be set globally in config/tests.exs. Some can be overridden per test.

All options:

  • :accept_dialogs (boolean/0) - Accept browser dialogs (alert(), confirm(), prompt()). The default value is true.

  • :assets_dir (binary/0) - The directory where the JS assets are located and the Playwright CLI is installed. Playwright version 1.55.0 or newer is recommended. Alternatively, use ws_endpoint to connect to a remote Playwright server instead, in which case no local node and playwright is required and assets_dir is ignored. The default value is "./assets".

  • :browser (:android | :chromium | :electron | :firefox | :webkit) - The default value is :chromium.

  • :browser_context_opts - Additional arguments passed to Playwright Browser.newContext. E.g. [http_credentials: %{username: "a", password: "b"}]. The default value is [].

  • :browser_launch_timeout (non_neg_integer/0) - The default value is 4000.

  • :browser_page_opts - Additional arguments passed to Playwright Browser.newPage. (E.g. [accept_downloads: false]. The default value is [].

  • :browser_pool (atom | false) - Reuse a browser from this pool instead of launching a new browser per test suite. false to disable pooling and launch a new browser per test suite. The default value is :default_pool.

  • :browser_pool_checkout_timeout (non_neg_integer/0) - The default value is 60000.

  • :browser_pools (list of non-empty keyword/0) - Supported keys:

    • :id (atom/0) - Required.

    • :size (integer/0) - The default value is System.schedulers_online() / 2.

    • :browser (:android | :chromium | :electron | :firefox | :webkit) - The default value is :chromium.

    • :browser_launch_timeout (non_neg_integer/0) - The default value is 4000.

    • :executable_path (String.t/0) - Path to a browser executable to run instead of the bundled one. Use at your own risk.

    • :headless (boolean/0) - The default value is true.

    • :slow_mo (non_neg_integer/0) - The default value is 0.

    The default value is [[id: :default_pool]].

  • :ecto_sandbox_stop_owner_delay (non_neg_integer/0) - Delay in milliseconds before shutting down the Ecto sandbox owner after a test ends. Use this to allow LiveViews and other processes in your app time to stop using database connections before the sandbox owner is terminated. The default value is 0.

  • :executable_path (String.t/0) - Path to a browser executable to run instead of the bundled one. Use at your own risk.

  • :headless (boolean/0) - The default value is true.

  • :js_logger (module | false) - false to disable, or a module that implements the PlaywrightEx.JsLogger behaviour. The default value is PhoenixTest.Playwright.JsLogger.

  • :screenshot (boolean/0 | Keyword.t/0) - Either a boolean or a keyword list:

    • :full_page (boolean/0) - The default value is true.

    • :omit_background (boolean/0) - The default value is false.

    The default value is false.

  • :screenshot_dir (String.t/0) - The default value is "screenshots".

  • :selector_engines - Define custom Playwright selector engines. The default value is [].

  • :slow_mo (non_neg_integer/0) - The default value is 0.

  • :timeout (non_neg_integer/0) - The default value is 2000.

  • :trace (boolean/0 | :open) - The default value is false.

  • :trace_dir (String.t/0) - The default value is "traces".

  • :ws_endpoint (String.t/0) - WebSocket endpoint URL for connecting to a remote Playwright server. If provided, uses WebSocket transport instead of spawning a local Node.js process. Example: "ws://localhost:3000/ws"

    The remote server provides a single pre-launched browser, so browser_pool should be set to false (pooling has no effect with a remote server).

    This is useful for:

    • Alpine Linux containers (glibc issues with local Playwright driver)
    • Containerized CI environments with a separate Playwright server
    • Connecting to remote/shared Playwright instances

Options that be overridden per test module via the use PhoenixTest.Playwright.Case opts:

  • :browser_pool
  • :browser
  • :browser_launch_timeout
  • :executable_path
  • :headless
  • :slow_mo

Options that be overridden per test via ExUnit @tag:

  • :accept_dialogs
  • :ecto_sandbox_stop_owner_delay
  • :screenshot
  • :trace
  • :browser_context_opts
  • :browser_page_opts