executable-stories-cypress 8.0.0 → 8.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -38,7 +38,8 @@ function getContext() {
38
38
  }
39
39
  function normalizeTickets(ticket) {
40
40
  if (!ticket) return void 0;
41
- return Array.isArray(ticket) ? ticket : [ticket];
41
+ const arr = Array.isArray(ticket) ? ticket : [ticket];
42
+ return arr.map((t) => typeof t === "string" ? { id: t } : t);
42
43
  }
43
44
  function convertStoryDocsToEntries(docs) {
44
45
  const entries = [];
@@ -123,8 +124,17 @@ function convertStoryDocsToEntries(docs) {
123
124
  }
124
125
  return entries;
125
126
  }
126
- function attachDoc(entry) {
127
+ function attachDoc(entry, children) {
127
128
  const ctx = getContext();
129
+ if (children && children.length > 0) {
130
+ entry.children = children;
131
+ const childSet = new Set(children);
132
+ const filterDocs = (docs) => docs.filter((d) => !childSet.has(d));
133
+ ctx.meta.docs = filterDocs(ctx.meta.docs ?? []);
134
+ for (const step of ctx.meta.steps) {
135
+ if (step.docs) step.docs = filterDocs(step.docs);
136
+ }
137
+ }
128
138
  if (ctx.currentStep) {
129
139
  ctx.currentStep.docs ??= [];
130
140
  ctx.currentStep.docs.push(entry);
@@ -132,6 +142,7 @@ function attachDoc(entry) {
132
142
  ctx.meta.docs ??= [];
133
143
  ctx.meta.docs.push(entry);
134
144
  }
145
+ return entry;
135
146
  }
136
147
  function extractSuitePath(titlePath) {
137
148
  if (titlePath.length <= 1) return void 0;
@@ -142,16 +153,35 @@ function createStepMarker(keyword) {
142
153
  function stepMarker(text, docsOrBody) {
143
154
  const ctx = getContext();
144
155
  const isCallback = typeof docsOrBody === "function";
156
+ const isChildrenArray = Array.isArray(docsOrBody);
145
157
  const resolvedKeyword = (keyword === "Given" || keyword === "When" || keyword === "Then") && ctx.meta.steps.some((s) => s.keyword === keyword) ? "And" : keyword;
158
+ let stepDocs = [];
159
+ if (!isCallback && !isChildrenArray && docsOrBody) {
160
+ stepDocs = convertStoryDocsToEntries(docsOrBody);
161
+ }
146
162
  const step = {
147
163
  id: `step-${ctx.stepCounter++}`,
148
164
  keyword: resolvedKeyword,
149
165
  text,
150
- docs: !isCallback && docsOrBody ? convertStoryDocsToEntries(docsOrBody) : [],
166
+ docs: stepDocs,
151
167
  ...isCallback ? { wrapped: true } : {}
152
168
  };
153
169
  ctx.meta.steps.push(step);
154
170
  ctx.currentStep = step;
171
+ if (isChildrenArray) {
172
+ const children = docsOrBody;
173
+ if (children.length > 0) {
174
+ const childSet = new Set(children);
175
+ ctx.meta.docs = (ctx.meta.docs ?? []).filter((d) => !childSet.has(d));
176
+ for (const prevStep of ctx.meta.steps) {
177
+ if (prevStep !== step && prevStep.docs) {
178
+ prevStep.docs = prevStep.docs.filter((d) => !childSet.has(d));
179
+ }
180
+ }
181
+ step.docs = [...step.docs ?? [], ...children];
182
+ }
183
+ return;
184
+ }
155
185
  if (!isCallback) return;
156
186
  const body = docsOrBody;
157
187
  const start = performance.now();
@@ -214,7 +244,8 @@ function getAndClearMeta() {
214
244
  specRelative: activeContext.specRelative,
215
245
  titlePath: activeContext.titlePath,
216
246
  meta: activeContext.meta,
217
- attachments: activeContext.attachments.length > 0 ? activeContext.attachments : void 0
247
+ attachments: activeContext.attachments.length > 0 ? activeContext.attachments : void 0,
248
+ otelSpans: activeContext.otelSpans
218
249
  };
219
250
  activeContext = null;
220
251
  return payload;
@@ -275,40 +306,40 @@ var story = {
275
306
  action: createStepMarker("When"),
276
307
  verify: createStepMarker("Then"),
277
308
  // Standalone doc methods
278
- note(text) {
279
- attachDoc({ kind: "note", text, phase: "runtime" });
309
+ note(text, children) {
310
+ return attachDoc({ kind: "note", text, phase: "runtime" }, children);
280
311
  },
281
- tag(name) {
312
+ tag(name, children) {
282
313
  const names = Array.isArray(name) ? name : [name];
283
- attachDoc({ kind: "tag", names, phase: "runtime" });
314
+ return attachDoc({ kind: "tag", names, phase: "runtime" }, children);
284
315
  },
285
- kv(options) {
286
- attachDoc({ kind: "kv", label: options.label, value: options.value, phase: "runtime" });
316
+ kv(options, children) {
317
+ return attachDoc({ kind: "kv", label: options.label, value: options.value, phase: "runtime" }, children);
287
318
  },
288
- json(options) {
319
+ json(options, children) {
289
320
  const content = JSON.stringify(options.value, null, 2);
290
- attachDoc({ kind: "code", label: options.label, content, lang: "json", phase: "runtime" });
321
+ return attachDoc({ kind: "code", label: options.label, content, lang: "json", phase: "runtime" }, children);
291
322
  },
292
- code(options) {
293
- attachDoc({ kind: "code", label: options.label, content: options.content, lang: options.lang, phase: "runtime" });
323
+ code(options, children) {
324
+ return attachDoc({ kind: "code", label: options.label, content: options.content, lang: options.lang, phase: "runtime" }, children);
294
325
  },
295
- table(options) {
296
- attachDoc({ kind: "table", label: options.label, columns: options.columns, rows: options.rows, phase: "runtime" });
326
+ table(options, children) {
327
+ return attachDoc({ kind: "table", label: options.label, columns: options.columns, rows: options.rows, phase: "runtime" }, children);
297
328
  },
298
- link(options) {
299
- attachDoc({ kind: "link", label: options.label, url: options.url, phase: "runtime" });
329
+ link(options, children) {
330
+ return attachDoc({ kind: "link", label: options.label, url: options.url, phase: "runtime" }, children);
300
331
  },
301
- section(options) {
302
- attachDoc({ kind: "section", title: options.title, markdown: options.markdown, phase: "runtime" });
332
+ section(options, children) {
333
+ return attachDoc({ kind: "section", title: options.title, markdown: options.markdown, phase: "runtime" }, children);
303
334
  },
304
- mermaid(options) {
305
- attachDoc({ kind: "mermaid", code: options.code, title: options.title, phase: "runtime" });
335
+ mermaid(options, children) {
336
+ return attachDoc({ kind: "mermaid", code: options.code, title: options.title, phase: "runtime" }, children);
306
337
  },
307
- screenshot(options) {
308
- attachDoc({ kind: "screenshot", path: options.path, alt: options.alt, phase: "runtime" });
338
+ screenshot(options, children) {
339
+ return attachDoc({ kind: "screenshot", path: options.path, alt: options.alt, phase: "runtime" }, children);
309
340
  },
310
- custom(options) {
311
- attachDoc({ kind: "custom", type: options.type, data: options.data, phase: "runtime" });
341
+ custom(options, children) {
342
+ return attachDoc({ kind: "custom", type: options.type, data: options.data, phase: "runtime" }, children);
312
343
  },
313
344
  // Attachments
314
345
  attach(options) {
@@ -320,6 +351,11 @@ var story = {
320
351
  stepId: ctx.currentStep?.id
321
352
  });
322
353
  },
354
+ // OTel span attachment
355
+ attachSpans(spans) {
356
+ const ctx = getContext();
357
+ ctx.otelSpans = spans;
358
+ },
323
359
  // Step timing
324
360
  startTimer() {
325
361
  const ctx = getContext();
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/story-api.ts"],"sourcesContent":["/**\n * Cypress Executable Stories\n *\n * BDD-style executable documentation for Cypress.\n *\n * @example\n * ```ts\n * import { story } from 'executable-stories-cypress';\n *\n * describe('Calculator', () => {\n * it('adds two numbers', () => {\n * story.init();\n *\n * story.given('two numbers 5 and 3');\n * const a = 5, b = 3;\n *\n * story.when('I add them together');\n * const result = a + b;\n *\n * story.then('the result is 8');\n * expect(result).toBe(8);\n * });\n * });\n * ```\n */\n\n// Story API\nexport { story, getAndClearMeta } from './story-api';\nexport type { Story, RecordMetaPayload } from './story-api';\n\n// Re-export types from local types module\nexport type {\n StoryMeta,\n StoryStep,\n DocEntry,\n StepKeyword,\n StoryDocs,\n StoryOptions,\n KvOptions,\n JsonOptions,\n CodeOptions,\n TableOptions,\n LinkOptions,\n SectionOptions,\n MermaidOptions,\n ScreenshotOptions,\n CustomOptions,\n} from './types';\n","/**\n * Cypress story.* API for executable-stories.\n *\n * Uses native Cypress describe/it with opt-in documentation.\n * Story meta is flushed to Node via cy.task from the support file.\n *\n * @example\n * ```ts\n * import { story } from 'executable-stories-cypress';\n *\n * describe('Calculator', () => {\n * it('adds two numbers', () => {\n * story.init();\n *\n * story.given('two numbers 5 and 3');\n * const a = 5, b = 3;\n *\n * story.when('I add them together');\n * const result = a + b;\n *\n * story.then('the result is 8');\n * expect(result).toBe(8);\n * });\n * });\n * ```\n */\n\nimport type {\n StepKeyword,\n StoryMeta,\n StoryStep,\n DocEntry,\n StoryDocs,\n StoryOptions,\n AttachmentOptions,\n ScopedAttachment,\n RecordMetaPayload,\n KvOptions,\n JsonOptions,\n CodeOptions,\n TableOptions,\n LinkOptions,\n SectionOptions,\n MermaidOptions,\n ScreenshotOptions,\n CustomOptions,\n} from './types';\n\n// Re-export types for consumers\nexport type {\n StoryMeta,\n StoryStep,\n DocEntry,\n StepKeyword,\n StoryDocs,\n StoryOptions,\n AttachmentOptions,\n} from './types';\n\nexport type { RecordMetaPayload } from './types';\n\n// ============================================================================\n// Internal types\n// ============================================================================\n\ninterface TimerEntry {\n start: number;\n stepIndex?: number;\n stepId?: string;\n consumed: boolean;\n}\n\ninterface StoryContext {\n meta: StoryMeta;\n currentStep: StoryStep | null;\n stepCounter: number;\n attachments: ScopedAttachment[];\n activeTimers: Map<number, TimerEntry>;\n timerCounter: number;\n specRelative: string;\n titlePath: string[];\n}\n\n// ============================================================================\n// Cypress-specific context\n// ============================================================================\n\n/** Active story context - set by story.init() */\nlet activeContext: StoryContext | null = null;\n\n/** Counter to track source order of stories (increments on each story.init call) */\nlet sourceOrderCounter = 0;\n\n/**\n * Get the current story context. Throws if story.init() wasn't called.\n */\nfunction getContext(): StoryContext {\n if (!activeContext) {\n throw new Error(\n \"story.init() must be called first. Use: it('name', () => { story.init(); ... });\"\n );\n }\n return activeContext;\n}\n\n// ============================================================================\n// Helper functions (inlined from core)\n// ============================================================================\n\nfunction normalizeTickets(ticket: string | string[] | undefined): string[] | undefined {\n if (!ticket) return undefined;\n return Array.isArray(ticket) ? ticket : [ticket];\n}\n\nfunction convertStoryDocsToEntries(docs: StoryDocs): DocEntry[] {\n const entries: DocEntry[] = [];\n\n if (docs.note) {\n entries.push({ kind: 'note', text: docs.note, phase: 'runtime' });\n }\n if (docs.tag) {\n const names = Array.isArray(docs.tag) ? docs.tag : [docs.tag];\n entries.push({ kind: 'tag', names, phase: 'runtime' });\n }\n if (docs.kv) {\n for (const [label, value] of Object.entries(docs.kv)) {\n entries.push({ kind: 'kv', label, value, phase: 'runtime' });\n }\n }\n if (docs.code) {\n entries.push({\n kind: 'code',\n label: docs.code.label,\n content: docs.code.content,\n lang: docs.code.lang,\n phase: 'runtime',\n });\n }\n if (docs.json) {\n entries.push({\n kind: 'code',\n label: docs.json.label,\n content: JSON.stringify(docs.json.value, null, 2),\n lang: 'json',\n phase: 'runtime',\n });\n }\n if (docs.table) {\n entries.push({\n kind: 'table',\n label: docs.table.label,\n columns: docs.table.columns,\n rows: docs.table.rows,\n phase: 'runtime',\n });\n }\n if (docs.link) {\n entries.push({\n kind: 'link',\n label: docs.link.label,\n url: docs.link.url,\n phase: 'runtime',\n });\n }\n if (docs.section) {\n entries.push({\n kind: 'section',\n title: docs.section.title,\n markdown: docs.section.markdown,\n phase: 'runtime',\n });\n }\n if (docs.mermaid) {\n entries.push({\n kind: 'mermaid',\n code: docs.mermaid.code,\n title: docs.mermaid.title,\n phase: 'runtime',\n });\n }\n if (docs.screenshot) {\n entries.push({\n kind: 'screenshot',\n path: docs.screenshot.path,\n alt: docs.screenshot.alt,\n phase: 'runtime',\n });\n }\n if (docs.custom) {\n entries.push({\n kind: 'custom',\n type: docs.custom.type,\n data: docs.custom.data,\n phase: 'runtime',\n });\n }\n\n return entries;\n}\n\nfunction attachDoc(entry: DocEntry): void {\n const ctx = getContext();\n if (ctx.currentStep) {\n ctx.currentStep.docs ??= [];\n ctx.currentStep.docs.push(entry);\n } else {\n ctx.meta.docs ??= [];\n ctx.meta.docs.push(entry);\n }\n}\n\n/**\n * Extract suite path from Cypress.currentTest.titlePath (describe blocks only).\n * titlePath is [describe1, describe2, ..., testTitle] — we want everything except the last.\n */\nfunction extractSuitePath(titlePath: string[]): string[] | undefined {\n if (titlePath.length <= 1) return undefined;\n const suitePath = titlePath.slice(0, -1);\n return suitePath.length > 0 ? suitePath : undefined;\n}\n\n// ============================================================================\n// Step markers\n// ============================================================================\n\nfunction createStepMarker(keyword: StepKeyword) {\n function stepMarker(text: string, docs?: StoryDocs): void;\n function stepMarker<T>(text: string, body: () => T): T;\n function stepMarker<T>(text: string, docsOrBody?: StoryDocs | (() => T)): T | void {\n const ctx = getContext();\n const isCallback = typeof docsOrBody === 'function';\n\n const resolvedKeyword: StepKeyword =\n (keyword === 'Given' || keyword === 'When' || keyword === 'Then') &&\n ctx.meta.steps.some((s) => s.keyword === keyword)\n ? 'And'\n : keyword;\n\n const step: StoryStep = {\n id: `step-${ctx.stepCounter++}`,\n keyword: resolvedKeyword,\n text,\n docs: (!isCallback && docsOrBody) ? convertStoryDocsToEntries(docsOrBody) : [],\n ...(isCallback ? { wrapped: true } : {}),\n };\n\n ctx.meta.steps.push(step);\n ctx.currentStep = step;\n\n if (!isCallback) return;\n\n const body = docsOrBody as () => T;\n const start = performance.now();\n\n try {\n const result = body();\n if (result instanceof Promise) {\n return result.then(\n (val) => { step.durationMs = performance.now() - start; return val; },\n (err) => { step.durationMs = performance.now() - start; throw err; },\n ) as T;\n }\n step.durationMs = performance.now() - start;\n return result;\n } catch (err) {\n step.durationMs = performance.now() - start;\n throw err;\n }\n }\n return stepMarker;\n}\n\n// ============================================================================\n// story.init() - Cypress-specific\n// ============================================================================\n\nfunction init(options?: StoryOptions): void {\n const currentTest = Cypress.currentTest;\n const spec = Cypress.spec;\n if (!currentTest) {\n throw new Error(\"story.init() must be called inside an it() block so Cypress.currentTest is available.\");\n }\n\n const titlePath = currentTest.titlePath ?? [currentTest.title];\n const scenario = currentTest.title;\n const suitePath = extractSuitePath(titlePath);\n const specRelative = spec?.relative ?? \"unknown\";\n\n const meta: StoryMeta = {\n scenario,\n steps: [],\n suitePath,\n tags: options?.tags,\n tickets: normalizeTickets(options?.ticket),\n meta: options?.meta,\n sourceOrder: sourceOrderCounter++,\n };\n\n activeContext = {\n meta,\n currentStep: null,\n stepCounter: 0,\n attachments: [],\n activeTimers: new Map(),\n timerCounter: 0,\n specRelative,\n titlePath,\n };\n}\n\n/**\n * Get the current story meta and clear the active context.\n * Called by the support file after each test to send meta to Node via cy.task.\n * Returns null if story.init() was never called for this test.\n */\nexport function getAndClearMeta(): RecordMetaPayload | null {\n if (!activeContext) return null;\n const payload: RecordMetaPayload = {\n specRelative: activeContext.specRelative,\n titlePath: activeContext.titlePath,\n meta: activeContext.meta,\n attachments: activeContext.attachments.length > 0 ? activeContext.attachments : undefined,\n };\n activeContext = null;\n return payload;\n}\n\n// ============================================================================\n// story.fn() and story.expect()\n// ============================================================================\n\n/**\n * Wrap a function as a step with timing and error capture.\n * Records the step with `wrapped: true` and `durationMs`.\n */\nfunction fn<T>(keyword: StepKeyword, text: string, body: () => T): T {\n const ctx = getContext();\n\n const resolvedKeyword: StepKeyword =\n (keyword === 'Given' || keyword === 'When' || keyword === 'Then') &&\n ctx.meta.steps.some((s) => s.keyword === keyword)\n ? 'And'\n : keyword;\n\n const step: StoryStep = {\n id: `step-${ctx.stepCounter++}`,\n keyword: resolvedKeyword,\n text,\n docs: [],\n wrapped: true,\n };\n ctx.meta.steps.push(step);\n ctx.currentStep = step;\n\n const start = performance.now();\n try {\n const result = body();\n if (result instanceof Promise) {\n return result.then(\n (val) => {\n step.durationMs = performance.now() - start;\n return val;\n },\n (err) => {\n step.durationMs = performance.now() - start;\n throw err;\n },\n ) as T;\n }\n step.durationMs = performance.now() - start;\n return result;\n } catch (err) {\n step.durationMs = performance.now() - start;\n throw err;\n }\n}\n\n/**\n * Wrap an assertion as a Then step with timing and error capture.\n * Shorthand for `story.fn('Then', text, body)`.\n */\nfunction storyExpect<T>(text: string, body: () => T): T {\n return fn('Then', text, body);\n}\n\n// ============================================================================\n// Export story object\n// ============================================================================\n\nexport const story = {\n init,\n\n // BDD step markers\n given: createStepMarker('Given'),\n when: createStepMarker('When'),\n then: createStepMarker('Then'),\n and: createStepMarker('And'),\n but: createStepMarker('But'),\n\n // AAA pattern aliases\n arrange: createStepMarker('Given'),\n act: createStepMarker('When'),\n assert: createStepMarker('Then'),\n\n // Additional aliases\n setup: createStepMarker('Given'),\n context: createStepMarker('Given'),\n execute: createStepMarker('When'),\n action: createStepMarker('When'),\n verify: createStepMarker('Then'),\n\n // Standalone doc methods\n note(text: string): void {\n attachDoc({ kind: 'note', text, phase: 'runtime' });\n },\n\n tag(name: string | string[]): void {\n const names = Array.isArray(name) ? name : [name];\n attachDoc({ kind: 'tag', names, phase: 'runtime' });\n },\n\n kv(options: KvOptions): void {\n attachDoc({ kind: 'kv', label: options.label, value: options.value, phase: 'runtime' });\n },\n\n json(options: JsonOptions): void {\n const content = JSON.stringify(options.value, null, 2);\n attachDoc({ kind: 'code', label: options.label, content, lang: 'json', phase: 'runtime' });\n },\n\n code(options: CodeOptions): void {\n attachDoc({ kind: 'code', label: options.label, content: options.content, lang: options.lang, phase: 'runtime' });\n },\n\n table(options: TableOptions): void {\n attachDoc({ kind: 'table', label: options.label, columns: options.columns, rows: options.rows, phase: 'runtime' });\n },\n\n link(options: LinkOptions): void {\n attachDoc({ kind: 'link', label: options.label, url: options.url, phase: 'runtime' });\n },\n\n section(options: SectionOptions): void {\n attachDoc({ kind: 'section', title: options.title, markdown: options.markdown, phase: 'runtime' });\n },\n\n mermaid(options: MermaidOptions): void {\n attachDoc({ kind: 'mermaid', code: options.code, title: options.title, phase: 'runtime' });\n },\n\n screenshot(options: ScreenshotOptions): void {\n attachDoc({ kind: 'screenshot', path: options.path, alt: options.alt, phase: 'runtime' });\n },\n\n custom(options: CustomOptions): void {\n attachDoc({ kind: 'custom', type: options.type, data: options.data, phase: 'runtime' });\n },\n\n // Attachments\n attach(options: AttachmentOptions): void {\n const ctx = getContext();\n const stepIndex = ctx.currentStep\n ? ctx.meta.steps.indexOf(ctx.currentStep)\n : undefined;\n ctx.attachments.push({\n ...options,\n stepIndex: stepIndex !== undefined && stepIndex >= 0 ? stepIndex : undefined,\n stepId: ctx.currentStep?.id,\n });\n },\n\n // Step timing\n startTimer(): number {\n const ctx = getContext();\n const token = ctx.timerCounter++;\n const stepIndex = ctx.currentStep\n ? ctx.meta.steps.indexOf(ctx.currentStep)\n : undefined;\n ctx.activeTimers.set(token, {\n start: performance.now(),\n stepIndex: stepIndex !== undefined && stepIndex >= 0 ? stepIndex : undefined,\n stepId: ctx.currentStep?.id,\n consumed: false,\n });\n return token;\n },\n\n endTimer(token: number): void {\n const ctx = getContext();\n const entry = ctx.activeTimers.get(token);\n if (!entry || entry.consumed) return;\n\n entry.consumed = true;\n const durationMs = performance.now() - entry.start;\n\n let step: StoryStep | undefined;\n if (entry.stepId) {\n step = ctx.meta.steps.find((s) => s.id === entry.stepId);\n }\n if (!step && entry.stepIndex !== undefined) {\n step = ctx.meta.steps[entry.stepIndex];\n }\n\n if (step) {\n step.durationMs = durationMs;\n }\n },\n\n // Step wrappers\n fn,\n expect: storyExpect,\n};\n\nexport type Story = typeof story;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACwFA,IAAI,gBAAqC;AAGzC,IAAI,qBAAqB;AAKzB,SAAS,aAA2B;AAClC,MAAI,CAAC,eAAe;AAClB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAMA,SAAS,iBAAiB,QAA6D;AACrF,MAAI,CAAC,OAAQ,QAAO;AACpB,SAAO,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC,MAAM;AACjD;AAEA,SAAS,0BAA0B,MAA6B;AAC9D,QAAM,UAAsB,CAAC;AAE7B,MAAI,KAAK,MAAM;AACb,YAAQ,KAAK,EAAE,MAAM,QAAQ,MAAM,KAAK,MAAM,OAAO,UAAU,CAAC;AAAA,EAClE;AACA,MAAI,KAAK,KAAK;AACZ,UAAM,QAAQ,MAAM,QAAQ,KAAK,GAAG,IAAI,KAAK,MAAM,CAAC,KAAK,GAAG;AAC5D,YAAQ,KAAK,EAAE,MAAM,OAAO,OAAO,OAAO,UAAU,CAAC;AAAA,EACvD;AACA,MAAI,KAAK,IAAI;AACX,eAAW,CAAC,OAAO,KAAK,KAAK,OAAO,QAAQ,KAA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,QAAI,CAAC,SAAS,MAAM,SAAU;AAE9B,UAAM,WAAW;AACjB,UAAM,aAAa,YAAY,IAAI,IAAI,MAAM;AAE7C,QAAI;AACJ,QAAI,MAAM,QAAQ;AAChB,aAAO,IAAI,KAAK,MAAM,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM,MAAM;AAAA,IACzD;AACA,QAAI,CAAC,QAAQ,MAAM,cAAc,QAAW;AAC1C,aAAO,IAAI,KAAK,MAAM,MAAM,SAAS;AAAA,IACvC;AAEA,QAAI,MAAM;AACR,WAAK,aAAa;AAAA,IACpB;AAAA,EACF;AAAA;AAAA,EAGA;AAAA,EACA,QAAQ;AACV;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/story-api.ts"],"sourcesContent":["/**\n * Cypress Executable Stories\n *\n * BDD-style executable documentation for Cypress.\n *\n * @example\n * ```ts\n * import { story } from 'executable-stories-cypress';\n *\n * describe('Calculator', () => {\n * it('adds two numbers', () => {\n * story.init();\n *\n * story.given('two numbers 5 and 3');\n * const a = 5, b = 3;\n *\n * story.when('I add them together');\n * const result = a + b;\n *\n * story.then('the result is 8');\n * expect(result).toBe(8);\n * });\n * });\n * ```\n */\n\n// Story API\nexport { story, getAndClearMeta } from './story-api';\nexport type { Story, RecordMetaPayload } from './story-api';\n\n// Re-export types from local types module\nexport type {\n StoryMeta,\n StoryStep,\n DocEntry,\n StepKeyword,\n StoryDocs,\n StoryOptions,\n KvOptions,\n JsonOptions,\n CodeOptions,\n TableOptions,\n LinkOptions,\n SectionOptions,\n MermaidOptions,\n ScreenshotOptions,\n CustomOptions,\n} from './types';\n","/**\n * Cypress story.* API for executable-stories.\n *\n * Uses native Cypress describe/it with opt-in documentation.\n * Story meta is flushed to Node via cy.task from the support file.\n *\n * @example\n * ```ts\n * import { story } from 'executable-stories-cypress';\n *\n * describe('Calculator', () => {\n * it('adds two numbers', () => {\n * story.init();\n *\n * story.given('two numbers 5 and 3');\n * const a = 5, b = 3;\n *\n * story.when('I add them together');\n * const result = a + b;\n *\n * story.then('the result is 8');\n * expect(result).toBe(8);\n * });\n * });\n * ```\n */\n\nimport type {\n StepKeyword,\n StoryMeta,\n StoryStep,\n DocEntry,\n StoryDocs,\n StoryOptions,\n AttachmentOptions,\n ScopedAttachment,\n RecordMetaPayload,\n NormalizedTicket,\n TicketInput,\n KvOptions,\n JsonOptions,\n CodeOptions,\n TableOptions,\n LinkOptions,\n SectionOptions,\n MermaidOptions,\n ScreenshotOptions,\n CustomOptions,\n} from './types';\n\n// Re-export types for consumers\nexport type {\n StoryMeta,\n StoryStep,\n DocEntry,\n StepKeyword,\n StoryDocs,\n StoryOptions,\n AttachmentOptions,\n NormalizedTicket,\n TicketInput,\n} from './types';\n\nexport type { RecordMetaPayload } from './types';\n\n// ============================================================================\n// Internal types\n// ============================================================================\n\ninterface TimerEntry {\n start: number;\n stepIndex?: number;\n stepId?: string;\n consumed: boolean;\n}\n\ninterface StoryContext {\n meta: StoryMeta;\n currentStep: StoryStep | null;\n stepCounter: number;\n attachments: ScopedAttachment[];\n activeTimers: Map<number, TimerEntry>;\n timerCounter: number;\n specRelative: string;\n titlePath: string[];\n otelSpans?: ReadonlyArray<Record<string, unknown>>;\n}\n\n// ============================================================================\n// Cypress-specific context\n// ============================================================================\n\n/** Active story context - set by story.init() */\nlet activeContext: StoryContext | null = null;\n\n/** Counter to track source order of stories (increments on each story.init call) */\nlet sourceOrderCounter = 0;\n\n/**\n * Get the current story context. Throws if story.init() wasn't called.\n */\nfunction getContext(): StoryContext {\n if (!activeContext) {\n throw new Error(\n \"story.init() must be called first. Use: it('name', () => { story.init(); ... });\"\n );\n }\n return activeContext;\n}\n\n// ============================================================================\n// Helper functions (inlined from core)\n// ============================================================================\n\nfunction normalizeTickets(\n ticket: TicketInput | TicketInput[] | undefined,\n): NormalizedTicket[] | undefined {\n if (!ticket) return undefined;\n const arr = Array.isArray(ticket) ? ticket : [ticket];\n return arr.map((t) => (typeof t === 'string' ? { id: t } : t));\n}\n\nfunction convertStoryDocsToEntries(docs: StoryDocs): DocEntry[] {\n const entries: DocEntry[] = [];\n\n if (docs.note) {\n entries.push({ kind: 'note', text: docs.note, phase: 'runtime' });\n }\n if (docs.tag) {\n const names = Array.isArray(docs.tag) ? docs.tag : [docs.tag];\n entries.push({ kind: 'tag', names, phase: 'runtime' });\n }\n if (docs.kv) {\n for (const [label, value] of Object.entries(docs.kv)) {\n entries.push({ kind: 'kv', label, value, phase: 'runtime' });\n }\n }\n if (docs.code) {\n entries.push({\n kind: 'code',\n label: docs.code.label,\n content: docs.code.content,\n lang: docs.code.lang,\n phase: 'runtime',\n });\n }\n if (docs.json) {\n entries.push({\n kind: 'code',\n label: docs.json.label,\n content: JSON.stringify(docs.json.value, null, 2),\n lang: 'json',\n phase: 'runtime',\n });\n }\n if (docs.table) {\n entries.push({\n kind: 'table',\n label: docs.table.label,\n columns: docs.table.columns,\n rows: docs.table.rows,\n phase: 'runtime',\n });\n }\n if (docs.link) {\n entries.push({\n kind: 'link',\n label: docs.link.label,\n url: docs.link.url,\n phase: 'runtime',\n });\n }\n if (docs.section) {\n entries.push({\n kind: 'section',\n title: docs.section.title,\n markdown: docs.section.markdown,\n phase: 'runtime',\n });\n }\n if (docs.mermaid) {\n entries.push({\n kind: 'mermaid',\n code: docs.mermaid.code,\n title: docs.mermaid.title,\n phase: 'runtime',\n });\n }\n if (docs.screenshot) {\n entries.push({\n kind: 'screenshot',\n path: docs.screenshot.path,\n alt: docs.screenshot.alt,\n phase: 'runtime',\n });\n }\n if (docs.custom) {\n entries.push({\n kind: 'custom',\n type: docs.custom.type,\n data: docs.custom.data,\n phase: 'runtime',\n });\n }\n\n return entries;\n}\n\nfunction attachDoc(entry: DocEntry, children?: DocEntry[]): DocEntry {\n const ctx = getContext();\n if (children && children.length > 0) {\n entry.children = children;\n const childSet = new Set<DocEntry>(children);\n const filterDocs = (docs: DocEntry[]) => docs.filter((d) => !childSet.has(d));\n // Remove children from ALL containers (story-level + every step)\n ctx.meta.docs = filterDocs(ctx.meta.docs ?? []);\n for (const step of ctx.meta.steps) {\n if (step.docs) step.docs = filterDocs(step.docs);\n }\n }\n if (ctx.currentStep) {\n ctx.currentStep.docs ??= [];\n ctx.currentStep.docs.push(entry);\n } else {\n ctx.meta.docs ??= [];\n ctx.meta.docs.push(entry);\n }\n return entry;\n}\n\n/**\n * Extract suite path from Cypress.currentTest.titlePath (describe blocks only).\n * titlePath is [describe1, describe2, ..., testTitle] — we want everything except the last.\n */\nfunction extractSuitePath(titlePath: string[]): string[] | undefined {\n if (titlePath.length <= 1) return undefined;\n const suitePath = titlePath.slice(0, -1);\n return suitePath.length > 0 ? suitePath : undefined;\n}\n\n// ============================================================================\n// Step markers\n// ============================================================================\n\nfunction createStepMarker(keyword: StepKeyword) {\n function stepMarker(text: string, docs?: StoryDocs): void;\n function stepMarker(text: string, children: DocEntry[]): void;\n function stepMarker<T>(text: string, body: () => T): T;\n function stepMarker<T>(text: string, docsOrBody?: StoryDocs | DocEntry[] | (() => T)): T | void {\n const ctx = getContext();\n const isCallback = typeof docsOrBody === 'function';\n const isChildrenArray = Array.isArray(docsOrBody);\n\n const resolvedKeyword: StepKeyword =\n (keyword === 'Given' || keyword === 'When' || keyword === 'Then') &&\n ctx.meta.steps.some((s) => s.keyword === keyword)\n ? 'And'\n : keyword;\n\n let stepDocs: DocEntry[] = [];\n if (!isCallback && !isChildrenArray && docsOrBody) {\n stepDocs = convertStoryDocsToEntries(docsOrBody as StoryDocs);\n }\n\n const step: StoryStep = {\n id: `step-${ctx.stepCounter++}`,\n keyword: resolvedKeyword,\n text,\n docs: stepDocs,\n ...(isCallback ? { wrapped: true } : {}),\n };\n\n ctx.meta.steps.push(step);\n ctx.currentStep = step;\n\n // Handle DocEntry[] children: attach as step docs and deduplicate from story-level\n if (isChildrenArray) {\n const children = docsOrBody as DocEntry[];\n if (children.length > 0) {\n const childSet = new Set<DocEntry>(children);\n // Deduplicate from story-level docs\n ctx.meta.docs = (ctx.meta.docs ?? []).filter((d) => !childSet.has(d));\n // Deduplicate from step docs of earlier steps\n for (const prevStep of ctx.meta.steps) {\n if (prevStep !== step && prevStep.docs) {\n prevStep.docs = prevStep.docs.filter((d) => !childSet.has(d));\n }\n }\n step.docs = [...(step.docs ?? []), ...children];\n }\n return;\n }\n\n if (!isCallback) return;\n\n const body = docsOrBody as () => T;\n const start = performance.now();\n\n try {\n const result = body();\n if (result instanceof Promise) {\n return result.then(\n (val) => { step.durationMs = performance.now() - start; return val; },\n (err) => { step.durationMs = performance.now() - start; throw err; },\n ) as T;\n }\n step.durationMs = performance.now() - start;\n return result;\n } catch (err) {\n step.durationMs = performance.now() - start;\n throw err;\n }\n }\n return stepMarker;\n}\n\n// ============================================================================\n// story.init() - Cypress-specific\n// ============================================================================\n\nfunction init(options?: StoryOptions): void {\n const currentTest = Cypress.currentTest;\n const spec = Cypress.spec;\n if (!currentTest) {\n throw new Error(\"story.init() must be called inside an it() block so Cypress.currentTest is available.\");\n }\n\n const titlePath = currentTest.titlePath ?? [currentTest.title];\n const scenario = currentTest.title;\n const suitePath = extractSuitePath(titlePath);\n const specRelative = spec?.relative ?? \"unknown\";\n\n const meta: StoryMeta = {\n scenario,\n steps: [],\n suitePath,\n tags: options?.tags,\n tickets: normalizeTickets(options?.ticket),\n meta: options?.meta,\n sourceOrder: sourceOrderCounter++,\n };\n\n activeContext = {\n meta,\n currentStep: null,\n stepCounter: 0,\n attachments: [],\n activeTimers: new Map(),\n timerCounter: 0,\n specRelative,\n titlePath,\n };\n}\n\n/**\n * Get the current story meta and clear the active context.\n * Called by the support file after each test to send meta to Node via cy.task.\n * Returns null if story.init() was never called for this test.\n */\nexport function getAndClearMeta(): RecordMetaPayload | null {\n if (!activeContext) return null;\n const payload: RecordMetaPayload = {\n specRelative: activeContext.specRelative,\n titlePath: activeContext.titlePath,\n meta: activeContext.meta,\n attachments: activeContext.attachments.length > 0 ? activeContext.attachments : undefined,\n otelSpans: activeContext.otelSpans,\n };\n activeContext = null;\n return payload;\n}\n\n// ============================================================================\n// story.fn() and story.expect()\n// ============================================================================\n\n/**\n * Wrap a function as a step with timing and error capture.\n * Records the step with `wrapped: true` and `durationMs`.\n */\nfunction fn<T>(keyword: StepKeyword, text: string, body: () => T): T {\n const ctx = getContext();\n\n const resolvedKeyword: StepKeyword =\n (keyword === 'Given' || keyword === 'When' || keyword === 'Then') &&\n ctx.meta.steps.some((s) => s.keyword === keyword)\n ? 'And'\n : keyword;\n\n const step: StoryStep = {\n id: `step-${ctx.stepCounter++}`,\n keyword: resolvedKeyword,\n text,\n docs: [],\n wrapped: true,\n };\n ctx.meta.steps.push(step);\n ctx.currentStep = step;\n\n const start = performance.now();\n try {\n const result = body();\n if (result instanceof Promise) {\n return result.then(\n (val) => {\n step.durationMs = performance.now() - start;\n return val;\n },\n (err) => {\n step.durationMs = performance.now() - start;\n throw err;\n },\n ) as T;\n }\n step.durationMs = performance.now() - start;\n return result;\n } catch (err) {\n step.durationMs = performance.now() - start;\n throw err;\n }\n}\n\n/**\n * Wrap an assertion as a Then step with timing and error capture.\n * Shorthand for `story.fn('Then', text, body)`.\n */\nfunction storyExpect<T>(text: string, body: () => T): T {\n return fn('Then', text, body);\n}\n\n// ============================================================================\n// Export story object\n// ============================================================================\n\nexport const story = {\n init,\n\n // BDD step markers\n given: createStepMarker('Given'),\n when: createStepMarker('When'),\n then: createStepMarker('Then'),\n and: createStepMarker('And'),\n but: createStepMarker('But'),\n\n // AAA pattern aliases\n arrange: createStepMarker('Given'),\n act: createStepMarker('When'),\n assert: createStepMarker('Then'),\n\n // Additional aliases\n setup: createStepMarker('Given'),\n context: createStepMarker('Given'),\n execute: createStepMarker('When'),\n action: createStepMarker('When'),\n verify: createStepMarker('Then'),\n\n // Standalone doc methods\n note(text: string, children?: DocEntry[]): DocEntry {\n return attachDoc({ kind: 'note', text, phase: 'runtime' }, children);\n },\n\n tag(name: string | string[], children?: DocEntry[]): DocEntry {\n const names = Array.isArray(name) ? name : [name];\n return attachDoc({ kind: 'tag', names, phase: 'runtime' }, children);\n },\n\n kv(options: KvOptions, children?: DocEntry[]): DocEntry {\n return attachDoc({ kind: 'kv', label: options.label, value: options.value, phase: 'runtime' }, children);\n },\n\n json(options: JsonOptions, children?: DocEntry[]): DocEntry {\n const content = JSON.stringify(options.value, null, 2);\n return attachDoc({ kind: 'code', label: options.label, content, lang: 'json', phase: 'runtime' }, children);\n },\n\n code(options: CodeOptions, children?: DocEntry[]): DocEntry {\n return attachDoc({ kind: 'code', label: options.label, content: options.content, lang: options.lang, phase: 'runtime' }, children);\n },\n\n table(options: TableOptions, children?: DocEntry[]): DocEntry {\n return attachDoc({ kind: 'table', label: options.label, columns: options.columns, rows: options.rows, phase: 'runtime' }, children);\n },\n\n link(options: LinkOptions, children?: DocEntry[]): DocEntry {\n return attachDoc({ kind: 'link', label: options.label, url: options.url, phase: 'runtime' }, children);\n },\n\n section(options: SectionOptions, children?: DocEntry[]): DocEntry {\n return attachDoc({ kind: 'section', title: options.title, markdown: options.markdown, phase: 'runtime' }, children);\n },\n\n mermaid(options: MermaidOptions, children?: DocEntry[]): DocEntry {\n return attachDoc({ kind: 'mermaid', code: options.code, title: options.title, phase: 'runtime' }, children);\n },\n\n screenshot(options: ScreenshotOptions, children?: DocEntry[]): DocEntry {\n return attachDoc({ kind: 'screenshot', path: options.path, alt: options.alt, phase: 'runtime' }, children);\n },\n\n custom(options: CustomOptions, children?: DocEntry[]): DocEntry {\n return attachDoc({ kind: 'custom', type: options.type, data: options.data, phase: 'runtime' }, children);\n },\n\n // Attachments\n attach(options: AttachmentOptions): void {\n const ctx = getContext();\n const stepIndex = ctx.currentStep\n ? ctx.meta.steps.indexOf(ctx.currentStep)\n : undefined;\n ctx.attachments.push({\n ...options,\n stepIndex: stepIndex !== undefined && stepIndex >= 0 ? stepIndex : undefined,\n stepId: ctx.currentStep?.id,\n });\n },\n\n // OTel span attachment\n attachSpans(spans: ReadonlyArray<Record<string, unknown>>): void {\n const ctx = getContext();\n ctx.otelSpans = spans;\n },\n\n // Step timing\n startTimer(): number {\n const ctx = getContext();\n const token = ctx.timerCounter++;\n const stepIndex = ctx.currentStep\n ? ctx.meta.steps.indexOf(ctx.currentStep)\n : undefined;\n ctx.activeTimers.set(token, {\n start: performance.now(),\n stepIndex: stepIndex !== undefined && stepIndex >= 0 ? stepIndex : undefined,\n stepId: ctx.currentStep?.id,\n consumed: false,\n });\n return token;\n },\n\n endTimer(token: number): void {\n const ctx = getContext();\n const entry = ctx.activeTimers.get(token);\n if (!entry || entry.consumed) return;\n\n entry.consumed = true;\n const durationMs = performance.now() - entry.start;\n\n let step: StoryStep | undefined;\n if (entry.stepId) {\n step = ctx.meta.steps.find((s) => s.id === entry.stepId);\n }\n if (!step && entry.stepIndex !== undefined) {\n step = ctx.meta.steps[entry.stepIndex];\n }\n\n if (step) {\n step.durationMs = durationMs;\n }\n },\n\n // Step wrappers\n fn,\n expect: storyExpect,\n};\n\nexport type Story = typeof story;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC6FA,IAAI,gBAAqC;AAGzC,IAAI,qBAAqB;AAKzB,SAAS,aAA2B;AAClC,MAAI,CAAC,eAAe;AAClB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAMA,SAAS,iBACP,QACgC;AAChC,MAAI,CAAC,OAAQ,QAAO;AACpB,QAAM,MAAM,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC,MAAM;AACpD,SAAO,IAAI,IAAI,CAAC,MAAO,OAAO,MAAM,WAAW,EAAE,IAAI,EAAE,IAAI,CAAE;AAC/D;AAEA,SAAS,0BAA0B,MAA6B;AAC9D,QAAM,UAAsB,CAAC;AAE7B,MAAI,KAAK,MAAM;AACb,YAAQ,KAAK,EAAE,MAAM,QAAQ,MAAM,KAAK,MAAM,OAAO,UAAU,CAAC;AAAA,EAClE;AACA,MAAI,KAAK,KAAK;AACZ,UAAM,QAAQ,MAAM,QAAQ,K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;AAAA,MAC1B,OAAO,YAAY,IAAI;AAAA,MACvB,WAAW,cAAc,UAAa,aAAa,IAAI,YAAY;AAAA,MACnE,QAAQ,IAAI,aAAa;AAAA,MACzB,UAAU;AAAA,IACZ,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,SAAS,OAAqB;AAC5B,UAAM,MAAM,WAAW;AACvB,UAAM,QAAQ,IAAI,aAAa,IAAI,KAAK;AACxC,QAAI,CAAC,SAAS,MAAM,SAAU;AAE9B,UAAM,WAAW;AACjB,UAAM,aAAa,YAAY,IAAI,IAAI,MAAM;AAE7C,QAAI;AACJ,QAAI,MAAM,QAAQ;AAChB,aAAO,IAAI,KAAK,MAAM,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM,MAAM;AAAA,IACzD;AACA,QAAI,CAAC,QAAQ,MAAM,cAAc,QAAW;AAC1C,aAAO,IAAI,KAAK,MAAM,MAAM,SAAS;AAAA,IACvC;AAEA,QAAI,MAAM;AACR,WAAK,aAAa;AAAA,IACpB;AAAA,EACF;AAAA;AAAA,EAGA;AAAA,EACA,QAAQ;AACV;","names":[]}
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { StoryMeta as StoryMeta$1, StepKeyword } from 'executable-stories-formatters';
1
+ import { StoryMeta as StoryMeta$1, DocEntry, StepKeyword } from 'executable-stories-formatters';
2
2
  export { DocEntry, StepKeyword, StoryMeta, StoryStep } from 'executable-stories-formatters';
3
3
 
4
4
  /**
@@ -6,6 +6,11 @@ export { DocEntry, StepKeyword, StoryMeta, StoryStep } from 'executable-stories-
6
6
  * No Cypress or Node-only imports so both environments can use them.
7
7
  */
8
8
 
9
+ /** A ticket reference: either a plain string ID or an object with id and optional url */
10
+ type TicketInput = string | {
11
+ id: string;
12
+ url?: string;
13
+ };
9
14
  type StoryMeta = StoryMeta$1;
10
15
  /** Scoped attachment stored in context. */
11
16
  interface ScopedAttachment {
@@ -25,6 +30,7 @@ interface RecordMetaPayload {
25
30
  titlePath: string[];
26
31
  meta: StoryMeta;
27
32
  attachments?: ScopedAttachment[];
33
+ otelSpans?: ReadonlyArray<Record<string, unknown>>;
28
34
  }
29
35
  /** All inline doc options that can be passed to step markers. */
30
36
  interface StoryDocs {
@@ -43,7 +49,7 @@ interface StoryDocs {
43
49
  /** Options for story.init(). */
44
50
  interface StoryOptions {
45
51
  tags?: string[];
46
- ticket?: string | string[];
52
+ ticket?: TicketInput | TicketInput[];
47
53
  meta?: Record<string, unknown>;
48
54
  }
49
55
  /** Options for story.attach(). */
@@ -140,68 +146,82 @@ declare const story: {
140
146
  init: typeof init;
141
147
  given: {
142
148
  (text: string, docs?: StoryDocs): void;
149
+ (text: string, children: DocEntry[]): void;
143
150
  <T>(text: string, body: () => T): T;
144
151
  };
145
152
  when: {
146
153
  (text: string, docs?: StoryDocs): void;
154
+ (text: string, children: DocEntry[]): void;
147
155
  <T>(text: string, body: () => T): T;
148
156
  };
149
157
  then: {
150
158
  (text: string, docs?: StoryDocs): void;
159
+ (text: string, children: DocEntry[]): void;
151
160
  <T>(text: string, body: () => T): T;
152
161
  };
153
162
  and: {
154
163
  (text: string, docs?: StoryDocs): void;
164
+ (text: string, children: DocEntry[]): void;
155
165
  <T>(text: string, body: () => T): T;
156
166
  };
157
167
  but: {
158
168
  (text: string, docs?: StoryDocs): void;
169
+ (text: string, children: DocEntry[]): void;
159
170
  <T>(text: string, body: () => T): T;
160
171
  };
161
172
  arrange: {
162
173
  (text: string, docs?: StoryDocs): void;
174
+ (text: string, children: DocEntry[]): void;
163
175
  <T>(text: string, body: () => T): T;
164
176
  };
165
177
  act: {
166
178
  (text: string, docs?: StoryDocs): void;
179
+ (text: string, children: DocEntry[]): void;
167
180
  <T>(text: string, body: () => T): T;
168
181
  };
169
182
  assert: {
170
183
  (text: string, docs?: StoryDocs): void;
184
+ (text: string, children: DocEntry[]): void;
171
185
  <T>(text: string, body: () => T): T;
172
186
  };
173
187
  setup: {
174
188
  (text: string, docs?: StoryDocs): void;
189
+ (text: string, children: DocEntry[]): void;
175
190
  <T>(text: string, body: () => T): T;
176
191
  };
177
192
  context: {
178
193
  (text: string, docs?: StoryDocs): void;
194
+ (text: string, children: DocEntry[]): void;
179
195
  <T>(text: string, body: () => T): T;
180
196
  };
181
197
  execute: {
182
198
  (text: string, docs?: StoryDocs): void;
199
+ (text: string, children: DocEntry[]): void;
183
200
  <T>(text: string, body: () => T): T;
184
201
  };
185
202
  action: {
186
203
  (text: string, docs?: StoryDocs): void;
204
+ (text: string, children: DocEntry[]): void;
187
205
  <T>(text: string, body: () => T): T;
188
206
  };
189
207
  verify: {
190
208
  (text: string, docs?: StoryDocs): void;
209
+ (text: string, children: DocEntry[]): void;
191
210
  <T>(text: string, body: () => T): T;
192
211
  };
193
- note(text: string): void;
194
- tag(name: string | string[]): void;
195
- kv(options: KvOptions): void;
196
- json(options: JsonOptions): void;
197
- code(options: CodeOptions): void;
198
- table(options: TableOptions): void;
199
- link(options: LinkOptions): void;
200
- section(options: SectionOptions): void;
201
- mermaid(options: MermaidOptions): void;
202
- screenshot(options: ScreenshotOptions): void;
203
- custom(options: CustomOptions): void;
212
+ note(text: string, children?: DocEntry[]): DocEntry;
213
+ tag(name: string | string[], children?: DocEntry[]): DocEntry;
214
+ kv(options: KvOptions, children?: DocEntry[]): DocEntry;
215
+ json(options: JsonOptions, children?: DocEntry[]): DocEntry;
216
+ code(options: CodeOptions, children?: DocEntry[]): DocEntry;
217
+ table(options: TableOptions, children?: DocEntry[]): DocEntry;
218
+ link(options: LinkOptions, children?: DocEntry[]): DocEntry;
219
+ section(options: SectionOptions, children?: DocEntry[]): DocEntry;
220
+ mermaid(options: MermaidOptions, children?: DocEntry[]): DocEntry;
221
+ screenshot(options: ScreenshotOptions, children?: DocEntry[]): DocEntry;
222
+ custom(options: CustomOptions, children?: DocEntry[]): DocEntry;
204
223
  attach(options: AttachmentOptions): void;
224
+ attachSpans(spans: ReadonlyArray<Record<string, unknown>>): void;
205
225
  startTimer(): number;
206
226
  endTimer(token: number): void;
207
227
  fn: typeof fn;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { StoryMeta as StoryMeta$1, StepKeyword } from 'executable-stories-formatters';
1
+ import { StoryMeta as StoryMeta$1, DocEntry, StepKeyword } from 'executable-stories-formatters';
2
2
  export { DocEntry, StepKeyword, StoryMeta, StoryStep } from 'executable-stories-formatters';
3
3
 
4
4
  /**
@@ -6,6 +6,11 @@ export { DocEntry, StepKeyword, StoryMeta, StoryStep } from 'executable-stories-
6
6
  * No Cypress or Node-only imports so both environments can use them.
7
7
  */
8
8
 
9
+ /** A ticket reference: either a plain string ID or an object with id and optional url */
10
+ type TicketInput = string | {
11
+ id: string;
12
+ url?: string;
13
+ };
9
14
  type StoryMeta = StoryMeta$1;
10
15
  /** Scoped attachment stored in context. */
11
16
  interface ScopedAttachment {
@@ -25,6 +30,7 @@ interface RecordMetaPayload {
25
30
  titlePath: string[];
26
31
  meta: StoryMeta;
27
32
  attachments?: ScopedAttachment[];
33
+ otelSpans?: ReadonlyArray<Record<string, unknown>>;
28
34
  }
29
35
  /** All inline doc options that can be passed to step markers. */
30
36
  interface StoryDocs {
@@ -43,7 +49,7 @@ interface StoryDocs {
43
49
  /** Options for story.init(). */
44
50
  interface StoryOptions {
45
51
  tags?: string[];
46
- ticket?: string | string[];
52
+ ticket?: TicketInput | TicketInput[];
47
53
  meta?: Record<string, unknown>;
48
54
  }
49
55
  /** Options for story.attach(). */
@@ -140,68 +146,82 @@ declare const story: {
140
146
  init: typeof init;
141
147
  given: {
142
148
  (text: string, docs?: StoryDocs): void;
149
+ (text: string, children: DocEntry[]): void;
143
150
  <T>(text: string, body: () => T): T;
144
151
  };
145
152
  when: {
146
153
  (text: string, docs?: StoryDocs): void;
154
+ (text: string, children: DocEntry[]): void;
147
155
  <T>(text: string, body: () => T): T;
148
156
  };
149
157
  then: {
150
158
  (text: string, docs?: StoryDocs): void;
159
+ (text: string, children: DocEntry[]): void;
151
160
  <T>(text: string, body: () => T): T;
152
161
  };
153
162
  and: {
154
163
  (text: string, docs?: StoryDocs): void;
164
+ (text: string, children: DocEntry[]): void;
155
165
  <T>(text: string, body: () => T): T;
156
166
  };
157
167
  but: {
158
168
  (text: string, docs?: StoryDocs): void;
169
+ (text: string, children: DocEntry[]): void;
159
170
  <T>(text: string, body: () => T): T;
160
171
  };
161
172
  arrange: {
162
173
  (text: string, docs?: StoryDocs): void;
174
+ (text: string, children: DocEntry[]): void;
163
175
  <T>(text: string, body: () => T): T;
164
176
  };
165
177
  act: {
166
178
  (text: string, docs?: StoryDocs): void;
179
+ (text: string, children: DocEntry[]): void;
167
180
  <T>(text: string, body: () => T): T;
168
181
  };
169
182
  assert: {
170
183
  (text: string, docs?: StoryDocs): void;
184
+ (text: string, children: DocEntry[]): void;
171
185
  <T>(text: string, body: () => T): T;
172
186
  };
173
187
  setup: {
174
188
  (text: string, docs?: StoryDocs): void;
189
+ (text: string, children: DocEntry[]): void;
175
190
  <T>(text: string, body: () => T): T;
176
191
  };
177
192
  context: {
178
193
  (text: string, docs?: StoryDocs): void;
194
+ (text: string, children: DocEntry[]): void;
179
195
  <T>(text: string, body: () => T): T;
180
196
  };
181
197
  execute: {
182
198
  (text: string, docs?: StoryDocs): void;
199
+ (text: string, children: DocEntry[]): void;
183
200
  <T>(text: string, body: () => T): T;
184
201
  };
185
202
  action: {
186
203
  (text: string, docs?: StoryDocs): void;
204
+ (text: string, children: DocEntry[]): void;
187
205
  <T>(text: string, body: () => T): T;
188
206
  };
189
207
  verify: {
190
208
  (text: string, docs?: StoryDocs): void;
209
+ (text: string, children: DocEntry[]): void;
191
210
  <T>(text: string, body: () => T): T;
192
211
  };
193
- note(text: string): void;
194
- tag(name: string | string[]): void;
195
- kv(options: KvOptions): void;
196
- json(options: JsonOptions): void;
197
- code(options: CodeOptions): void;
198
- table(options: TableOptions): void;
199
- link(options: LinkOptions): void;
200
- section(options: SectionOptions): void;
201
- mermaid(options: MermaidOptions): void;
202
- screenshot(options: ScreenshotOptions): void;
203
- custom(options: CustomOptions): void;
212
+ note(text: string, children?: DocEntry[]): DocEntry;
213
+ tag(name: string | string[], children?: DocEntry[]): DocEntry;
214
+ kv(options: KvOptions, children?: DocEntry[]): DocEntry;
215
+ json(options: JsonOptions, children?: DocEntry[]): DocEntry;
216
+ code(options: CodeOptions, children?: DocEntry[]): DocEntry;
217
+ table(options: TableOptions, children?: DocEntry[]): DocEntry;
218
+ link(options: LinkOptions, children?: DocEntry[]): DocEntry;
219
+ section(options: SectionOptions, children?: DocEntry[]): DocEntry;
220
+ mermaid(options: MermaidOptions, children?: DocEntry[]): DocEntry;
221
+ screenshot(options: ScreenshotOptions, children?: DocEntry[]): DocEntry;
222
+ custom(options: CustomOptions, children?: DocEntry[]): DocEntry;
204
223
  attach(options: AttachmentOptions): void;
224
+ attachSpans(spans: ReadonlyArray<Record<string, unknown>>): void;
205
225
  startTimer(): number;
206
226
  endTimer(token: number): void;
207
227
  fn: typeof fn;