Conditional Execution
Run a request only when it makes sense.
Add when: to a request and it runs only if the condition holds against values stored earlier. Write a one-line expression, or combine checks with all and any. Skipped requests are reported with the reason.
account.yaml
requests:
- name: Get account
url: https://api.example.com/account
store:
plan: body.plan
status: status
- name: Load premium reports
url: https://api.example.com/reports/premium
when: store.plan == premium
- name: Open an incident
url: https://api.example.com/incidents
method: POST
headers:
Content-Type: application/json
body: { source: smoke-test }
when:
any:
- { left: store.status, operator: ">=", right: 500 }
- { left: store.plan, operator: not-exists }Benefits
Readable conditions
store.plan == premium reads like what it does. Comparisons, contains, matches, exists and not-exists are built in.
Combine checks
all requires every condition, any needs just one — enough for real branching without a scripting language.
Visible skips
A skipped request shows up in the output and the summary, so nothing silently disappears from the run.
Good for
- Feature-flagged or plan-gated endpoints
- Cleanup steps that only run after a create
- Branching on an earlier status code
- Suites shared between environments