View Source Heyya.LiveComponentCase (heyya v1.0.0)

A test case template that provides helpers for testing live components. It relies on LiveComponentHost being mounted.

It allows for testing dyanmic content such as live components with a simplified stack.

## Usage

  # component_test.exs
  use Heyya.LiveComponentCase
  use ExampleWeb.ConnCase

  # By default LiveComponentCase will look for a render function in the module
  def render(assigns) do
    ~H|<.live_component module={ExampleWeb.LiveCounterComponent} id="example" />|
  end

  test "Test Counter", %{conn: conn} do
    conn
    |> start()
    |> click("button.increment")
    |> assert_html("Counter: 1")
  end

## Options

  • :view_module - The module that will render the live component
  • :view_method - The method that will render the live component
  • :base_path - The path to the live component host. Defaults to "/dev/heyya/host"

## Heyya.LiveComponentHost

The Heyya.LiveComponentHost is a live view that renders only a single live component with no other layout or content. It is used to test live components in isolation of so don't mount it in scope with complex Plugs.

  if Enum.member?([:dev, :test], Mix.env()) do
    scope "/dev" do
      pipe_through :browser
      live "/heyya/host", Heyya.LiveComponentHost
    end
  end

Summary

Functions