# `PhoenixMountable.TestHost`
[🔗](https://github.com/hattoriai/phoenix_mountable/blob/v0.2.1/lib/phoenix_mountable/test_host.ex#L2)

A host app for a mountable library's tests.

A mountable library has no router or endpoint of its own, so its tests need
a host to mount it in. Define one in `test/support`:

    defmodule MyLib.TestHost do
      use PhoenixMountable.TestHost,
        otp_app: :my_lib,
        mounts: [
          {MyLib.Router, "/my_lib", resolver: MyLib.TestResolver},
          {MyLib.Router, "/public", as: :public_lib}
        ]
    end

start it in `test/test_helper.exs`:

    MyLib.TestHost.start()

and use it from test cases:

    use PhoenixMountable.Test, host: MyLib.TestHost

    test "renders the home page", %{conn: conn} do
      {:ok, _view, html} = live(conn, "/my_lib")
      assert html =~ "Welcome"
    end

This defines `MyLib.TestHost.Router` and `MyLib.TestHost.Endpoint`. The
router's `:browser` pipeline fetches the session and flash and protects
from forgery, like a generated Phoenix app. Mounts are declared in the
order given, inside `scope "/"` with `pipe_through :browser`.

## Options

  * `:otp_app` — the application the endpoint reads its config from.
    Defaults to `:phoenix_mountable`.
  * `:mounts` — `{definition, path}` or `{definition, path, options}` tuples.
  * `:routes` — routes added to the host router after the mounts, for a
    host's own pages in tests, given as `(quote do ... end)`.

---

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