Skip to content

Installation (Cypress)

Terminal window
pnpm add -D executable-stories-cypress

Or with npm:

Terminal window
npm install -D executable-stories-cypress

In cypress.config.ts, register the executable-stories task so story meta can be sent from the browser to Node:

import { defineConfig } from 'cypress';
import { registerExecutableStoriesPlugin } from 'executable-stories-cypress/plugin';
export default defineConfig({
e2e: {
setupNodeEvents(on) {
registerExecutableStoriesPlugin(on);
},
},
});

Import the support file so story meta is sent after each test (e.g. in cypress/support/e2e.ts):

import 'executable-stories-cypress/support';

This registers an afterEach that sends collected story metadata to Node via cy.task.

To generate Markdown or HTML from Cypress runs you can:

  • Use the Mocha reporter when Cypress invokes it: --reporter executable-stories-cypress/reporter with --reporter-options outputDir=...,outputName=....
  • Or use the Module API: after cypress.run(), call buildRawRunFromCypressResult(result, options) then generateReportsFromRawRun(rawRun, options) (see exports from executable-stories-cypress/reporter).

Options match the formatters’ FormatterOptions (e.g. formats, outputDir, outputName, markdown). See Cypress reporter options for details.

First Story (Cypress) — write your first scenario and see the generated output.

Cypress reporter options — all configuration options.