Use case of bypass_through(conn)

Hi all

Could someone please explain me, what is the use case of

https://hexdocs.pm/phoenix/Phoenix.ConnTest.html#bypass_through/1

I read the doc but could not configure out for what does it for.

Thanks

1 Like

This is used in testing when you need a connection that has run through your endpoint, router, and pipelines/plugs. It gives you a connection that is all set up with the data transformations needed in your tests.

An example would be if you are testing a function that needs to fetch the session from the connection. The connection would need to be prepared (using bypass_through) for that.

3 Likes

It’s also worth pointing out that this is well documented in the link @kostonstyle posted above.

3 Likes