[**Documentation**](../../../../README)

***

[Documentation](../../../../README) / [@zerotal/flow](../../README) / [testing](../README) / FlowTest

# Class: FlowTest\<T\>

Defined in: [flow/src/testing.ts:51](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/flow/src/testing.ts#L51)

A fluent test harness around a single mounted Flow page/component. Obtain one with
[FlowTest.mount](#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`](../../index/classes/Component)

The Component subclass under test.

## Actions

### set()

> **set**(`prop`, `value`): `Promise`\<`FlowTest`\<`T`\>\>

Defined in: [flow/src/testing.ts:105](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/flow/src/testing.ts#L105)

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](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/flow/src/testing.ts#L117)

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](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/flow/src/testing.ts#L134)

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](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/flow/src/testing.ts#L192)

Assert the rendered HTML contains the given string.

#### Parameters

##### text

`string`

#### Returns

`this`

***

### assertDontSee()

> **assertDontSee**(`text`): `this`

Defined in: [flow/src/testing.ts:205](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/flow/src/testing.ts#L205)

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](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/flow/src/testing.ts#L218)

Assert the last action redirected to the given URL.

#### Parameters

##### url

`string`

#### Returns

`this`

***

### assertNotRedirected()

> **assertNotRedirected**(): `this`

Defined in: [flow/src/testing.ts:230](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/flow/src/testing.ts#L230)

Assert the last action did NOT redirect.

#### Returns

`this`

***

### assertHasErrors()

> **assertHasErrors**(`field`, `message?`): `this`

Defined in: [flow/src/testing.ts:244](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/flow/src/testing.ts#L244)

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](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/flow/src/testing.ts#L261)

Assert no validation errors exist.

#### Returns

`this`

***

### flashes()

> **flashes**(): [`FlashMessage`](../../index/interfaces/FlashMessage)[]

Defined in: [flow/src/testing.ts:278](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/flow/src/testing.ts#L278)

The full flash payloads emitted by the last action (title/position/duration/…).

#### Returns

[`FlashMessage`](../../index/interfaces/FlashMessage)[]

***

### assertFlashed()

> **assertFlashed**(`level?`, `message?`): `this`

Defined in: [flow/src/testing.ts:287](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/flow/src/testing.ts#L287)

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](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/flow/src/testing.ts#L307)

Assert a cross-component event was dispatched by the last action.

#### Parameters

##### eventName

`string`

#### Returns

`this`

## Lifecycle

### mount()

> `static` **mount**\<`T`\>(`PageClass`, `props?`): `Promise`\<`FlowTest`\<`T`\>\>

Defined in: [flow/src/testing.ts:79](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/flow/src/testing.ts#L79)

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`](../../index/classes/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

```ts
const t = await FlowTest.mount(DashboardPage);
```

## State

### html()

> **html**(): `string`

Defined in: [flow/src/testing.ts:323](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/flow/src/testing.ts#L323)

Get the rendered HTML.

#### Returns

`string`

***

### effects()

> **effects**(): [`FlowEffects`](../../index/interfaces/FlowEffects) \| `null`

Defined in: [flow/src/testing.ts:331](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/flow/src/testing.ts#L331)

Get the last drained effects (flashes, events, redirect, downloads).

#### Returns

[`FlowEffects`](../../index/interfaces/FlowEffects) \| `null`

***

### snapshot()

> **snapshot**(): [`Snapshot`](../../index/interfaces/Snapshot) \| `null`

Defined in: [flow/src/testing.ts:339](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/flow/src/testing.ts#L339)

Get the current page state snapshot.

#### Returns

[`Snapshot`](../../index/interfaces/Snapshot) \| `null`

***

### page()

> **page**(): `T`

Defined in: [flow/src/testing.ts:347](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/flow/src/testing.ts#L347)

Get the current page instance (for direct property inspection).

#### Returns

`T`

***

### errors()

> **errors**(): `Record`\<`string`, `string`[]\>

Defined in: [flow/src/testing.ts:355](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/flow/src/testing.ts#L355)

Get current validation errors.

#### Returns

`Record`\<`string`, `string`[]\>
