Reusing steps with flows
A flow is a list of steps with a name and parameters, like a function. Tests call: it. When the sign-in page changes, you fix the flow, and every test that signs in is fixed.
Write a flow
Section titled “Write a flow”A flow is a .sis.yaml file with flow: instead of name:. By convention they live in flows/:
sisyphus: 1flow: loginparams: [email, password]steps: - fill: textbox "Email" = ${email} - fill: textbox "Password" = ${password} - click: button "Sign in" - expect: heading "My todos"End a flow with a check that it worked (here, the heading after signing in). Then a broken sign-in fails at the flow, with a clear message, rather than three steps later somewhere confusing.
Call it
Section titled “Call it”steps: - call: login with: email: ada@example.com password: ${secret.PASSWORD} - click: button "New todo"If a step inside a flow fails, the result shows the flow’s file and line, and the test’s step that called it.
Default values
Section titled “Default values”A flow’s vars: are defaults for its parameters, so callers can leave them out:
flow: loginparams: [email, password]vars: email: demo@example.com- call: login with: { password: "${secret.PASSWORD}" }Run a flow before every test of an app
Section titled “Run a flow before every test of an app”If every test of an app starts by signing in, put the call on the app instead of in each test:
apps: web: url: http://localhost:3000 setup: - call: login with: { password: "${secret.PASSWORD}" }A test that must start signed out sets app_setup: false. If only some tests need it, define a second app with the same URL plus the setup (say web-signed-in), and let tests pick.
Let Sisyphus find repetition
Section titled “Let Sisyphus find repetition”sis validate notices when a test repeats a flow’s steps (three or more in a row) and suggests the call:. In Studio, the hint has a one-click fix, and Extract into a flow on a step moves selected steps into a new flow and replaces them with a call. The Flows tab shows each flow and which tests use it.
Flows, not chained tests
Section titled “Flows, not chained tests”Flows are how tests share steps. Don’t make one test depend on another having run first: each test calls the flows it needs and stands alone. See Writing good tests.
