View Source PhoenixTest.Playwright.Connection (PhoenixTestPlaywright v0.5.0)

Stateful, GenServer based connection to a Playwright node.js server. The connection is established via PhoenixTest.Playwright.Port.

The state is ever-growing and never pruned. Since we're dealing with (short-lived) tets, that is considered good enough for now.

The state includes

  • a tree of Playwright artifact guids,
  • all received messages,
  • sent message for which we're expecting a response.

You won't usually have to use this module directly. PhoenixTest.Playwright uses this under the hood.

Summary

Functions

Returns a specification to start this module under a supervisor.

Lazy launch. Only start the playwright server if actually needed by a test.

Get the initializer data for a channel.

Launch a browser and return its guid.

Post a message and await the response. We wait for an additional grace period after the timeout that we pass to playwright.

Get all past received messages for a playwright guid (e.g. a PhoenixTest.Playwright.Frame).

Subscribe to messages for a guid and its descendants.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

ensure_started()

Lazy launch. Only start the playwright server if actually needed by a test.

initializer(guid)

Get the initializer data for a channel.

launch_browser(type, opts)

Launch a browser and return its guid.

post(msg, timeout \\ nil)

Post a message and await the response. We wait for an additional grace period after the timeout that we pass to playwright.

received(guid)

Get all past received messages for a playwright guid (e.g. a PhoenixTest.Playwright.Frame).

start_link()

subscribe(pid \\ self(), guid)

Subscribe to messages for a guid and its descendants.