Skip to content

Recipes (pytest)

8 representative recipes showing key BDD patterns with pytest. The generated output is identical across all frameworks — only the test code differs.

AspectVitestpytest
Importimport { story } from 'executable-stories-vitest'from executable_stories import story
Initstory.init(task)story.init("scenario name")
Test functionit("name", ({ task }) => { ... })def test_name():
Stepsstory.given(...)story.given(...)
and stepstory.and(...)story.and_(...) (trailing underscore — and is a Python keyword)
Tagsstory.init(task, { tags: ["t1"] })story.init("name", tags=["t1"])
ScenarioPattern
User logs in successfullyMultiple Given (And auto-conversion)
Login worksStory with tags
Login blocked for suspended userUse of But
Checkout calculates totalsMultiple Then
Bulk user creationdoc.table
API accepts JSON payloaddoc.json
Import XML invoicedoc.code
Create orderBackground and tags

For the full 32-scenario set, see the Vitest recipes.