ExUnit assertion macros for Raxol MCP tests.
All assertions are pipe-friendly -- they return the session on success, so you can chain them:
session
|> click("btn")
|> assert_tool_available("btn.click")
|> assert_component("status", fn c -> c[:content] == "done" end)Usage
use ExUnit.Case
import Raxol.MCP.Test
import Raxol.MCP.Test.Assertions
Summary
Functions
Asserts a Component with the given ID exists in the current view tree.
Asserts the model matches a predicate function.
Asserts the text screenshot contains the given string.
Asserts the structured Component tree matches an expected shape.
Asserts a tool with the given name is available in the MCP registry.
Asserts that exactly N tools are registered.
Asserts a Component with the given ID does NOT exist in the view tree.
Asserts a tool is NOT available in the MCP registry.
Functions
Asserts a Component with the given ID exists in the current view tree.
Optionally takes a predicate function to check Component properties.
assert_component(session, "search_input")
assert_component(session, "counter", fn c -> c[:content] == "5" end)
Asserts the model matches a predicate function.
assert_model(session, fn model -> model.count == 5 end)
Asserts the text screenshot contains the given string.
assert_screenshot_contains(session, "Welcome")
Asserts the structured Component tree matches an expected shape.
The expected value is a list of maps with :type and optionally :id.
Uses subset matching -- each expected Component must appear somewhere
in the actual tree.
assert_screenshot_matches(session, [
%{type: :button, id: "submit"},
%{type: :text_input, id: "name"}
])
Asserts a tool with the given name is available in the MCP registry.
assert_tool_available(session, "search_input.type_into")
Asserts that exactly N tools are registered.
assert_tool_count(session, 5)
Asserts a Component with the given ID does NOT exist in the view tree.
refute_component(session, "deleted_item")
Asserts a tool is NOT available in the MCP registry.
refute_tool_available(session, "disabled_btn.click")