PhoenixTest.Playwright.BrowserPool (PhoenixTestPlaywright v0.9.1)
View SourceExperimental browser pooling. Reuses browsers across test suites.
This limits memory usage and is useful when running feature tests together with regular tests
(high ExUnit max_cases concurrency such as the default: 2x number of CPU cores).
Pools are defined up front. Browsers are launched lazily.
Usage:
# test/test_helper.exs
{:ok, _} =
Supervisor.start_link(
[
{PhoenixTest.Playwright.BrowserPool, name: :normal_chromium, size: System.schedulers_online(), browser: :chromium},
{PhoenixTest.Playwright.BrowserPool, name: :slow_chromium, size: 4, browser: :chromium, slow_mo: 100},
],
strategy: :one_for_one
)
# configure pool per test module
# test/my_test.exs
defmodule PhoenixTest.PlaywrightBrowserPoolTest do
use PhoenixTest.Playwright.Case,
async: true,
browser_pool: :normal_chromium
end
# or configure globally
# test/test.exs
config :phoenix_test,
playwright: [
browser_pool: :normal_chromium,
browser_pool_checkout_timeout: to_timeout(minute: 10)
]
Summary
Functions
Returns a specification to start this module under a supervisor.
Types
@type browser_id() :: binary()
@type pool() :: GenServer.server()
Functions
@spec checkout(pool()) :: browser_id()
Returns a specification to start this module under a supervisor.
See Supervisor.