Testing
Solid Native tests run in milliseconds in Node against a deterministic in-memory Fabric host (@solidnative-dev/testing)—no simulator boot required for component, navigation, or state logic.
Writing a component test#
Use renderNative to mount Solid Native TSX components, query by accessibility role or text, fire native events, and assert rendered output:
tsx
/** @jsxImportSource @solidnative-dev/core */
import assert from "node:assert/strict";
import test from "node:test";
import { renderNative } from "@solidnative-dev/testing";
import { Counter } from "./Counter";
test("increments counter on tap", async () => {
const screen = await renderNative(() => <Counter initial={4} />);
try {
const button = screen.getByRole("button", { name: "Increment" });
await screen.press(button);
assert.equal(screen.getByText("Count: 5").textContent, "Count: 5");
} finally {
await screen.cleanup();
}
});Running tests#
sn test discovers TSX/TS tests and runs them directly through Node's built-in test runner with the OXC Solid 2 universal TSX loader:
sh
# Run all discovered tests
sn test
# Watch mode or filtered subset
sn test --watch
sn test --test-name-pattern "counter"
# Verify behavior against the production Solid runtime build
sn test --productionWhat @solidnative-dev/testing covers#
- Accessibility & text queries:
getByRole,getByText,getByTestId,queryBy*,findBy*, andwaitFor. - Native event injection:
press,longPress,changeText,scroll, and custom native host events routed through the same dispatch path as Fabric. - Commit & mutation assertions: inspect exact atomic Fabric commits (
screen.commits,formatNativeTestCommits,formatNativeTestTree) to prove fine-grained updates never touch unrelated nodes. - Owner & teardown verification:
screen.cleanup()verifies every effect, subscription, and native resource releases cleanly with zero leaks.
Physical device verification#
Because host-independent tests cover JS reactivity and commit semantics, native rendering, gestures, 120 Hz animations, and platform APIs are qualified separately in Release mode on physical iOS and Android devices via XCTest and Android Instrumentation tests.