Skip to content

Testing API

render_to_tree

Convert a virtual element tree into JSON-friendly data.

By default, :class:streamtree.core.element.ComponentCall nodes are not executed (no Streamlit context required). Set expand_components=True to expand them; callers must wrap execution in :func:streamtree.core.context.render_context and have an active Streamlit session (st.session_state) when components use state().

:class:streamtree.elements.layout.Routes nodes appear as metadata (default, query_param, route_names) only; this helper does not call :func:streamtree.routing.sync_route or embed the active child subtree—use integration tests against Streamlit for routing behavior.

summarize_tree_kinds

Count kind values in nested dict/list structures from :func:render_to_tree.

Useful for lightweight assertions in tests and optional perf/debug summaries.

format_tree_text

Render a render_to_tree dict (or JSON-equivalent) as an indented outline.

tree_dict_to_mermaid

Build a Mermaid flowchart TD diagram from a render_to_tree dict.

Large trees and duplicate kind labels can make diagrams noisy; prefer :func:format_tree_text or JSON snapshots for dense UIs.