# `Volt.Test.Browser`
[🔗](https://github.com/elixir-volt/volt/blob/v0.23.0/lib/volt/test/browser.ex#L1)

The browser a test run shares.

Browsers are launched once per type, the first time a test asks for one,
and every test gets a browser context of its own, which isolates its
storage, cookies and pages the way a browser of its own would. See
`with_page/3`.

The process also keeps what the contexts load: the test runtime,
`priv/ts/test/browser.ts`, bundled once when the run starts and installed
in every context before its page loads, and the bundled test modules,
written to `_build/volt/browser-tests`, emptied when the run starts, and
reused while the source files they were bundled from keep their
modification times. See `module/2`.

`Volt.Test.Browser.Supervisor` starts this process next to the Playwright
driver.

# `launched`

```elixir
@type launched() :: %{guid: String.t()}
```

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `forget`

```elixir
@spec forget(atom(), String.t()) :: :ok
```

Drop a browser that is no longer reachable, so the next request launches a new one.

# `launch`

```elixir
@spec launch(atom(), timeout()) :: {:ok, launched()} | {:error, term()}
```

The browser of `type`, launched on first request.

# `module`

```elixir
@spec module(
  Path.t(),
  keyword()
) :: {:ok, String.t()} | {:error, term()}
```

The `file:` URL of the bundled module for the test file at `path`, bundled
with `bundle_opts`.

Bundling happens in the caller, so tests of different files bundle
concurrently. Modules are named by their content, so two callers bundling
the same file at once write the same module.

# `with_page`

```elixir
@spec with_page(atom(), timeout(), (map() -&gt; result)) :: result | {:error, term()}
when result: term()
```

Open a context in the browser of `type`, with the test runtime installed
and a page on the blank document, and call `fun` with the page's main frame.

The context closes when `fun` returns or raises. A browser that is no longer
reachable, because it crashed since it was launched, is launched again once.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
