Semantic test harness for Intent screens.
pnpm add -D @intent-framework/testingnpm install --save-dev @intent-framework/testingtestScreen()— create a runtime and run semantic assertions- Answer asks by setting state directly
- Assert action enabled/blocked state and blocked reasons
- Execute actions through the runtime
- Inspect feedback after action execution
- Test resource load, reload, invalidation, and staleness
import { test, expect } from "vitest"
import { testScreen } from "@intent-framework/testing"
import { screen } from "@intent-framework/core"
const InviteMember = screen("InviteMember", $ => {
const email = $.state.text("email")
const emailAsk = $.ask("Email", email)
.required()
.validate(value => value.includes("@") ? true : "Enter a valid email")
const invite = $.act("Invite member")
.primary()
.when(emailAsk.valid, "Enter a valid email first")
$.surface("main").contains(emailAsk, invite)
})
test("invite is blocked until email is valid", async () => {
await testScreen(InviteMember, async app => {
await app.act("Invite member").toBeBlockedBy("Enter a valid email first")
await app.answer("Email", "ada@example.com")
await app.act("Invite member").toBeEnabled()
})
})
test("invite action can be executed", async () => {
await testScreen(InviteMember, async app => {
await app.answer("Email", "ada@example.com")
await app.act("Invite member").run()
})
})No DOM, no selectors, no render waits. Tests speak product language.
Testing provides a runtime harness for Intent screens. It depends on @intent-framework/core. Use it with any test runner (Vitest recommended). It pairs with inspectScreen() for diagnostics assertions.
- Testing Harness Guide — full API reference, resource testing, services injection
- Root README — project overview and testing philosophy
- Quickstart — step-by-step guide with testing
- Canonical runnable example — matches the Quickstart one-to-one
Experimental alpha. APIs may change. Not recommended for production use.