Skip to content

Recipes (Vitest)

Each recipe shows how to implement a scenario in Vitest with executable-stories-vitest and the Markdown output the reporter produces. You use native describe / it and the story object: call story.init(task) at the start of each test (with task from it('...', ({ task }) => { ... })), then story.given, story.when, story.then (and story.and, story.but). Code is from the vitest-example app.

Scenario Recipe
User logs in successfully user-logs-in-successfully
User updates profile details user-updates-profile-details
Checkout calculates totals checkout-calculates-totals
Password reset flow password-reset-flow
Login blocked for suspended user login-blocked-suspended-user
Bulk user creation bulk-user-creation
Calculate shipping options calculate-shipping-options
API accepts a JSON payload api-accepts-json-payload
Import XML invoice import-xml-invoice
Change email address change-email-address
Change password change-password
Eligible customer gets discount eligible-customer-gets-discount
Ineligible customer does not get discount ineligible-customer-no-discount
Login errors (examples) login-errors
Tax calculation by region tax-calculation-by-region
Create users from table input create-users-from-table
Two step checkout two-step-checkout
Payment declined payment-declined
Login works (with tags) login-works
Update preferences update-preferences
Configure feature flags configure-feature-flags
Guest checkout allowed guest-checkout-allowed
Logout clears session logout-clears-session
Document status changes document-status-changes
Shipping eligibility shipping-eligibility
Render markdown render-markdown
Search results show highlights search-results-show-highlights
Post JSON payload post-json-payload
Create order create-order
Many login attempts many-login-attempts
Report shows fields in order report-shows-fields-in-order
Import users and send welcome email import-users-welcome-email

Source: apps/vitest-example/src/replicate.story.test.ts and generated replicate.story.docs.md.