#LiveView tests and logged in users

2 messages · Page 1 of 1 (latest)

mild shadow
#

Hi! What is the best way to test a liveView which require logged in user?

I've tried manually assigning the user to conn.assign.current_user but it arrives as nil on the pipeline.

I also tried with conn = Plug.Test.init_test_session(conn, %{current_user: user}) without success.

I can't find clear information about this, thank you!

wary imp
#

the quickest/easiest recommendation is to generate a new phoenix app and then run mix phx.gen.auth to generate basic user authentication, which will include tests that do exactly what you're asking