Cannot invoke handle_params/3 on LiveView because it is not mounted

Hi, I have mounted a LiveView in the router as follows:

router:ex

live "/users", UserLive, :index

However, I’m getting the following error message when I attempt to run tests:

mix test test/liveview_app_web/live/user_live_test.exs

** (ArgumentError) cannot invoke handle_params/3 on LiveviewAppWeb.UserLive.Index because it is not mounted nor accessed through the router live/3 macro

user_live_test.exs:

test "connected mount", ~M{conn} do
  {:ok, _view, html} = live(conn, UserLive)

   assert html =~ "Users"
end

live(conn, UserLive) doesn’t work for me, though with a different error:

** (RuntimeError) path must be nil or a binary, got: UserLive

Could you try changing it to live(conn, "/users") and see if it makes a difference?

1 Like

Hi, I decided to not use the handle_params and do any patching of the query params at this time. Thanks for providing a possible solution.