View Source Inertia.Testing (Inertia v2.0.0)

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

inertia_component(conn)

@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

inertia_props(conn)

@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