Cypress story & doc API
Cypress uses the same story.init() + story.* pattern as Jest (no task or testInfo). Call story.init([options]) at the start of each test, then use story.given, story.when, story.then, and doc methods on the story object. Story metadata is sent from the browser to Node via cy.task so the reporter can generate docs.
story.init([options])
Section titled “story.init([options])”Initializes a story for the current test. Must be called at the start of each test that wants documentation.
| Item | Description |
|---|---|
| options | Optional StoryOptions: tags, ticket, meta. |
| Example | it('adds two numbers', () => { story.init(); story.given('...'); ... }); |
Example with options:
it('admin deletes user', () => { story.init({ tags: ['admin', 'destructive'], ticket: 'JIRA-456', }); story.given('the admin is logged in'); story.when('the admin deletes the user'); story.then('the user is removed');});Step markers (story.given, story.when, story.then, story.and, story.but)
Section titled “Step markers (story.given, story.when, story.then, story.and, story.but)”Same as Vitest/Jest/Playwright: story.given, story.when, story.then, story.and, story.but, plus AAA aliases (arrange, act, assert, setup, context, execute, action, verify). Steps accept an optional second argument StoryDocs for inline docs.
Doc methods
Section titled “Doc methods”Same as other frameworks: story.note, story.tag, story.kv, story.json, story.code, story.table, story.link, story.section, story.mermaid, story.screenshot, story.custom — same signatures as Vitest story & doc API.
StoryOptions
Section titled “StoryOptions”| Option | Type | Default | Description |
|---|---|---|---|
tags | string[] | — | Tags for filtering and categorizing (e.g. ["smoke", "auth"]). |
ticket | string | string[] | — | Ticket/issue reference(s) for requirements traceability. |
meta | Record<string, unknown> | — | Arbitrary user-defined metadata. |
Unlike Vitest, Jest, and Playwright, Cypress does not currently expose a traceUrlTemplate story option because it uses a browser-to-Node reporting bridge instead of the Node test context used by the other adapters.
Exports
Section titled “Exports”- Main:
story,getAndClearMeta, types fromexecutable-stories-cypress. - Support:
executable-stories-cypress/support(side-effect: registersafterEach+cy.task). - Plugin:
registerExecutableStoriesPluginfromexecutable-stories-cypress/plugin. - Reporter: default reporter and
buildRawRunFromCypressResult,generateReportsFromRawRunfromexecutable-stories-cypress/reporter.