Phoenix.ConnTest.bypass_through/1

Parsed documentation:
View on GitHub
Calls the Endpoint and bypasses Router match.

Useful for unit testing Plugs where Endpoint and/or
router pipeline plugs are required for proper setup.

Note the use of `get("/")` following `bypass_through` in the examples below.
To execute the plug pipelines, you must issue a request against the router.
Most often, you can simpy send a GET request against the root path, but you
may also specify a different method or path which your pipelines may operate
against. If you ommit the request you may find that your tests return
a `flash not fetched, call fetch_flash/2` or similar error.

## Examples

For example, imagine you are testing an authentication
plug in isolation, but you need to invoke the Endpoint plugs
and `:browser` pipeline of your Router for session and flash
related dependencies:

    conn =
      conn
      |> bypass_through(MyAppWeb.Router, [:browser])
      |> get("/")
      |> MyApp.RequireAuthentication.call([])
    assert conn.halted

Alternatively, you could invoke only the Endpoint, and Router:

    conn =
      conn
      |> bypass_through(MyAppWeb.Router, [])
      |> get("/")
      |> MyApp.RequireAuthentication.call([])
    assert conn.halted

Or only invoke the Endpoint's plugs:

    conn =
      conn
      |> bypass_through()
      |> get("/")
      |> MyApp.RequireAuthentication.call([])
    assert conn.halted
Suggestions:
Please help! Open an issue on GitHub if this assessment is incorrect.