BloomTestRenderer class
Test harness wrapping a BloomNode AST tree for querying and assertion in VM tests.
Enables testing of Bloom components in standard dart test environments on the Dart VM
without requiring a browser DOM, JS runtime, or Flutter engine.
Provides querying utilities (queryBy* and getBy*) that traverse the descriptor hierarchy,
inspect attributes and text content, and support snapshot verification via toHtml.
BloomNode counterComponent(Signal<int> count) => Div(
attrs: {'data-testid': 'counter-root'},
children: [
Live(() => Span(attrs: {'data-testid': 'count-val'}, text: 'Count: ${count.value}')),
Button(
attrs: {'data-testid': 'inc-btn'},
onClick: (_) => count.value++,
text: 'Increment',
),
],
);
void main() {
test('increments counter on click', () {
final count = signal(0);
final renderer = renderForTest(counterComponent(count));
expect(renderer.getByTestId('count-val').text, 'Count: 0');
final btn = renderer.getByTestId('inc-btn');
fireEvent.click(btn);
expect(count.value, 1);
});
}
Constructors
- BloomTestRenderer(BloomNode root)
-
Creates a test renderer wrapping
root.const
Properties
Methods
-
getByTag(
String tag) → ElNode -
Finds the first ElNode whose HTML tag matches
tag(e.g.'button','div'). -
getByTestId(
String testId) → ElNode -
Finds the first ElNode in the tree whose
data-testidattribute matchestestId. -
getByText(
String text) → BloomNode -
Finds the first node whose direct text content equals
text. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
queryByTag(
String tag) → ElNode? -
Finds the first ElNode whose HTML tag matches
tag(e.g.'button','div'). -
queryByTestId(
String testId) → ElNode? -
Finds the first ElNode in the tree whose
data-testidattribute matchestestId. -
queryByText(
String text) → BloomNode? -
Finds the first node whose direct text content equals
text. -
toHtml(
) → String - Evaluates the tree through the SSR renderer and returns its rendered HTML string.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited