Reusable flows — browse guides

Reusable flows

Factor a repeated login or setup sequence into one named flow, reference it with a single step, and let Vera find the duplication for you.

Ten tests that each start by logging in contain the same six steps ten times. When the login form changes, you fix it ten times — and you find out you missed one when a run goes red for a reason that has nothing to do with what it was testing.

A flow is a named, reusable sequence of steps. Tests reference it with a single use-flow step, and the flow is inlined at run time.

Creating a flow

A flow belongs to a project and has a name, an optional description, and a list of steps. It is built with the same editor and the same actions as a test — a flow is a test body without the identity of a test.

The usual candidates are the sequences that are setup rather than subject: signing in, dismissing a cookie banner, seeding a cart, navigating to a deep page.

Using a flow

Add a use-flow step and pick the flow. That is the whole reference:

1  use-flow   Sign in as admin
2  goto       /settings/billing
3  assert     visible  [data-testid=invoice-table]

At run time the runner inlines the flow's steps in place of the use-flow step, before anything executes. The run you see is the flattened list, so a failure inside a flow points at the actual step that failed rather than at the reference.

Nesting

A flow may use another flow. Resolution is recursive with a maximum depth of 10 — deep enough for any legitimate composition, and a hard stop on a flow that references itself directly or through a cycle. Without that cap, a cycle would expand forever instead of failing.

Editing a flow changes every test that uses it

That is the point, and it is also the thing to be careful about. Tests do not hold a copy of the flow's steps; they hold a reference. Fix the login flow once and all ten tests are fixed. Break it once and all ten break — so a flow used widely is worth running one test against after you change it.

Factoring flows out of existing tests

You do not have to spot the duplication yourself. Vera can analyse a project's tests, find step sequences that repeat across them, and propose extracting each one as a flow — replacing the repeated steps with a use-flow reference in every test that had them.

It is a proposal, not an edit: you see what would be extracted and which tests would change before anything happens. AI-generated fleets go through the same factoring, which is why generating twelve tests for one app does not produce twelve copies of its login.

Variables inside flows

A flow's steps use {{tokens}} like any other step, resolved from the run's variable map — so one "Sign in" flow works for every role and every environment instead of needing a copy per credential set. See Variables.

See also