Documentation / @zerotal/admin / testing / FlowTest
Class: FlowTest<T>
Defined in: flow/src/testing.ts:51
A fluent test harness around a single mounted Flow page/component. Obtain one with
FlowTest.mount, drive state with set/update/call, then chain assertions
against the rendered HTML, redirects, validation errors, flashes, and dispatched events.
Every action and assertion returns this (or a Promise of it) for chaining.
Type Parameters
T
T extends Component
The Component subclass under test.
Actions
set()
set(
prop,value):Promise<FlowTest<T>>
Defined in: flow/src/testing.ts:105
Set a property value directly (state seeding), then return for chaining.
Does NOT fire the updating/updated hooks — use update() to simulate a
client-driven property change.
Parameters
prop
keyof T
value
unknown
Returns
Promise<FlowTest<T>>
update()
update(
prop,value):Promise<FlowTest<T>>
Defined in: flow/src/testing.ts:117
Simulate a client-driven property update (as a value/checked input or
$flow.$set would produce): routes through the allowlist and fires the
onUpdating() / onUpdated() hooks (and their per-property variants), then
re-renders.
Parameters
prop
keyof T
value
unknown
Returns
Promise<FlowTest<T>>
call()
call(
method, ...args):Promise<FlowTest<T>>
Defined in: flow/src/testing.ts:134
Call an action method and re-render. Simulates a subsequent (WebSocket) request:
runs onBoot() + onHydrate(), invokes the method, then onUpdate() and re-render.
If the action throws ValidationError, the errors are stored and the page re-renders
with the error bag populated; any other thrown error is routed to onError().
Parameters
method
string
Name of the method to invoke on the page.
args
...unknown[]
Arguments forwarded to the method.
Returns
Promise<FlowTest<T>>
Throws
If method is not a function on the page instance.
Assertions
assertSee()
assertSee(
text):this
Defined in: flow/src/testing.ts:192
Assert the rendered HTML contains the given string.
Parameters
text
string
Returns
this
assertDontSee()
assertDontSee(
text):this
Defined in: flow/src/testing.ts:205
Assert the rendered HTML does NOT contain the given string.
Parameters
text
string
Returns
this
assertRedirectedTo()
assertRedirectedTo(
url):this
Defined in: flow/src/testing.ts:218
Assert the last action redirected to the given URL.
Parameters
url
string
Returns
this
assertNotRedirected()
assertNotRedirected():
this
Defined in: flow/src/testing.ts:230
Assert the last action did NOT redirect.
Returns
this
assertHasErrors()
assertHasErrors(
field,message?):this
Defined in: flow/src/testing.ts:244
Assert that a validation error exists for the given field, optionally that one of
its messages contains message.
Parameters
field
string
message?
string
Returns
this
assertNoErrors()
assertNoErrors():
this
Defined in: flow/src/testing.ts:261
Assert no validation errors exist.
Returns
this
flashes()
flashes():
FlashMessage[]
Defined in: flow/src/testing.ts:278
The full flash payloads emitted by the last action (title/position/duration/…).
Returns
assertFlashed()
assertFlashed(
level?,message?):this
Defined in: flow/src/testing.ts:287
Assert a flash notification was emitted, optionally filtered by level and/or a
substring of its message.
Parameters
level?
string
message?
string
Returns
this
assertDispatched()
assertDispatched(
eventName):this
Defined in: flow/src/testing.ts:307
Assert a cross-component event was dispatched by the last action.
Parameters
eventName
string
Returns
this
Lifecycle
mount()
staticmount<T>(PageClass,props?):Promise<FlowTest<T>>
Defined in: flow/src/testing.ts:79
Mount a page: instantiate it, seed optional props, run its initial-request lifecycle
(onBoot() then onMount()), render once, and return the harness for chaining.
Type Parameters
T
T extends Component
Parameters
PageClass
PageClass<T>
The Component subclass to mount.
props?
Partial<T> = {}
Optional initial property values assigned before onMount() runs.
Returns
Promise<FlowTest<T>>
A resolved FlowTest wrapping the mounted page.
Example
const t = await FlowTest.mount(DashboardPage);
State
html()
html():
string
Defined in: flow/src/testing.ts:323
Get the rendered HTML.
Returns
string
effects()
effects():
FlowEffects|null
Defined in: flow/src/testing.ts:331
Get the last drained effects (flashes, events, redirect, downloads).
Returns
FlowEffects | null
snapshot()
snapshot():
Snapshot|null
Defined in: flow/src/testing.ts:339
Get the current page state snapshot.
Returns
Snapshot | null
page()
page():
T
Defined in: flow/src/testing.ts:347
Get the current page instance (for direct property inspection).
Returns
T
errors()
errors():
Record<string,string[]>
Defined in: flow/src/testing.ts:355
Get current validation errors.
Returns
Record<string, string[]>