Helpers for inspecting LiveViewReact roots in rendered LiveView HTML.
Examples
{:ok, view, _html} = live(conn, "/")
react = LiveViewReact.Test.get_react(view)
assert react.component == "MyComponent"
assert react.props["title"] == "Hello"Configuration
enable_props_diff
Set enable_props_diff to false to inspect full props on every render:
# config/test.exs
config :liveview_react,
enable_props_diff: false
Summary
Functions
Extracts React component information from a LiveView or HTML string.
Functions
Extracts React component information from a LiveView or HTML string.
When multiple roots are present, select one with :component or :id.
Returns a map containing the component's configuration:
:component- The registry component name:id- The required unique component identifier:props- The decoded props passed to the component:events- The encoded Phoenix JS command chains keyed by React callback prop:slots- decoded slot HTML keyed by slot name:ssr- Boolean indicating if server-side rendering was performed:hydration- The decoded immutable SSR hydration descriptor, ornil:props_kind-"snapshot"or"patch":streams_kind-"snapshot","patch", or"hydration":transport_version- the integer wire protocol version
Options
:component- Find a root by registry component name:id- Find component by ID
Examples
{:ok, view, _html} = live(conn, "/")
react = LiveViewReact.Test.get_react(view)
react = LiveViewReact.Test.get_react(view, component: "MyComponent")
react = LiveViewReact.Test.get_react(view, id: "my-component-1")