View Source Inertia.Testing (Inertia v1.0.0-beta.1)
Helpers for testing Inertia responses.
Summary
Functions
Fetches the Inertia component (if applicable) for the current request.
Fetches the Inertia props (if applicable) for the current request.
Functions
@spec inertia_component(Plug.Conn.t()) :: String.t() | nil
Fetches the Inertia component (if applicable) for the current request.
Example
use MyAppWeb.ConnCase
import Inertia.Testing
describe "GET /" do
test "renders the home page", %{conn: conn} do
conn = get("/")
assert inertia_component(conn) == "Home"
end
end
@spec inertia_props(Plug.Conn.t()) :: map() | nil
Fetches the Inertia props (if applicable) for the current request.
Example
use MyAppWeb.ConnCase
import Inertia.Testing
describe "GET /" do
test "renders the home page", %{conn: conn} do
conn = get("/")
assert %{user: %{id: 1}} = inertia_props(conn)
end
end