Passing data to session while testing in Elixir

Dec 01, 2020

I struggled a while when I tried to pass data to the session while setting up a Liveview test. I googled a lot and asked on the elixir slack for a solution, but everything I saw seemed quite complicated, and I didn’t manage to make it work.

I probably messed up something.

I finally found relief and a blog post with a one liner that does it :

Plug.Test.init_test_session(conn, user_id: 1)

The Plug documentation doesn’t say much more.