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.

ScenarioRecipe
User logs in successfullyuser-logs-in-successfully
User updates profile detailsuser-updates-profile-details
Checkout calculates totalscheckout-calculates-totals
Password reset flowpassword-reset-flow
Login blocked for suspended userlogin-blocked-suspended-user
Bulk user creationbulk-user-creation
Calculate shipping optionscalculate-shipping-options
API accepts a JSON payloadapi-accepts-json-payload
Import XML invoiceimport-xml-invoice
Change email addresschange-email-address
Change passwordchange-password
Eligible customer gets discounteligible-customer-gets-discount
Ineligible customer does not get discountineligible-customer-no-discount
Login errors (examples)login-errors
Tax calculation by regiontax-calculation-by-region
Create users from table inputcreate-users-from-table
Two step checkouttwo-step-checkout
Payment declinedpayment-declined
Login works (with tags)login-works
Update preferencesupdate-preferences
Configure feature flagsconfigure-feature-flags
Guest checkout allowedguest-checkout-allowed
Logout clears sessionlogout-clears-session
Document status changesdocument-status-changes
Shipping eligibilityshipping-eligibility
Render markdownrender-markdown
Search results show highlightssearch-results-show-highlights
Post JSON payloadpost-json-payload
Create ordercreate-order
Many login attemptsmany-login-attempts
Report shows fields in orderreport-shows-fields-in-order
Import users and send welcome emailimport-users-welcome-email

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