executable-stories-vitest 2.0.0

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.js ADDED
@@ -0,0 +1,401 @@
1
+ // src/story-api.ts
2
+ var activeContext = null;
3
+ var sourceOrderCounter = 0;
4
+ function getContext() {
5
+ if (!activeContext) {
6
+ throw new Error(
7
+ "story.init(task) must be called first. Use: it('name', ({ task }) => { story.init(task); ... });"
8
+ );
9
+ }
10
+ return activeContext;
11
+ }
12
+ function syncMetaToTask() {
13
+ if (activeContext?.taskMeta) {
14
+ activeContext.taskMeta.story = activeContext.meta;
15
+ }
16
+ }
17
+ function looksLikeFilePath(name) {
18
+ if (name.includes("/") || name.includes("\\")) return true;
19
+ if (name.includes(".spec.") || name.includes(".test.")) return true;
20
+ if (/\.(spec|test)\.(ts|js|mjs|cjs)$/.test(name)) return true;
21
+ if (/\.(ts|js|mjs|cjs)$/.test(name)) return true;
22
+ return false;
23
+ }
24
+ function extractSuitePath(task) {
25
+ const path = [];
26
+ const fileName = task.file?.name;
27
+ let current = task.suite;
28
+ while (current) {
29
+ const name = current.name;
30
+ if (name && name.trim() !== "" && name !== "<root>" && name !== fileName && !looksLikeFilePath(name)) {
31
+ path.unshift(name);
32
+ }
33
+ current = current.suite;
34
+ }
35
+ return path.length > 0 ? path : void 0;
36
+ }
37
+ function normalizeTickets(ticket) {
38
+ if (!ticket) return void 0;
39
+ return Array.isArray(ticket) ? ticket : [ticket];
40
+ }
41
+ function convertStoryDocsToEntries(docs) {
42
+ const entries = [];
43
+ if (docs.note) {
44
+ entries.push({ kind: "note", text: docs.note, phase: "runtime" });
45
+ }
46
+ if (docs.tag) {
47
+ const names = Array.isArray(docs.tag) ? docs.tag : [docs.tag];
48
+ entries.push({ kind: "tag", names, phase: "runtime" });
49
+ }
50
+ if (docs.kv) {
51
+ for (const [label, value] of Object.entries(docs.kv)) {
52
+ entries.push({ kind: "kv", label, value, phase: "runtime" });
53
+ }
54
+ }
55
+ if (docs.code) {
56
+ entries.push({
57
+ kind: "code",
58
+ label: docs.code.label,
59
+ content: docs.code.content,
60
+ lang: docs.code.lang,
61
+ phase: "runtime"
62
+ });
63
+ }
64
+ if (docs.json) {
65
+ entries.push({
66
+ kind: "code",
67
+ label: docs.json.label,
68
+ content: JSON.stringify(docs.json.value, null, 2),
69
+ lang: "json",
70
+ phase: "runtime"
71
+ });
72
+ }
73
+ if (docs.table) {
74
+ entries.push({
75
+ kind: "table",
76
+ label: docs.table.label,
77
+ columns: docs.table.columns,
78
+ rows: docs.table.rows,
79
+ phase: "runtime"
80
+ });
81
+ }
82
+ if (docs.link) {
83
+ entries.push({
84
+ kind: "link",
85
+ label: docs.link.label,
86
+ url: docs.link.url,
87
+ phase: "runtime"
88
+ });
89
+ }
90
+ if (docs.section) {
91
+ entries.push({
92
+ kind: "section",
93
+ title: docs.section.title,
94
+ markdown: docs.section.markdown,
95
+ phase: "runtime"
96
+ });
97
+ }
98
+ if (docs.mermaid) {
99
+ entries.push({
100
+ kind: "mermaid",
101
+ code: docs.mermaid.code,
102
+ title: docs.mermaid.title,
103
+ phase: "runtime"
104
+ });
105
+ }
106
+ if (docs.screenshot) {
107
+ entries.push({
108
+ kind: "screenshot",
109
+ path: docs.screenshot.path,
110
+ alt: docs.screenshot.alt,
111
+ phase: "runtime"
112
+ });
113
+ }
114
+ if (docs.custom) {
115
+ entries.push({
116
+ kind: "custom",
117
+ type: docs.custom.type,
118
+ data: docs.custom.data,
119
+ phase: "runtime"
120
+ });
121
+ }
122
+ return entries;
123
+ }
124
+ function init(task, options) {
125
+ const meta = {
126
+ scenario: task.name,
127
+ steps: [],
128
+ suitePath: extractSuitePath(task),
129
+ tags: options?.tags,
130
+ tickets: normalizeTickets(options?.ticket),
131
+ meta: options?.meta,
132
+ sourceOrder: sourceOrderCounter++
133
+ };
134
+ task.meta.story = meta;
135
+ activeContext = {
136
+ meta,
137
+ currentStep: null,
138
+ taskMeta: task.meta,
139
+ stepCounter: 0,
140
+ attachments: [],
141
+ activeTimers: /* @__PURE__ */ new Map(),
142
+ timerCounter: 0
143
+ };
144
+ }
145
+ function createStepMarker(keyword) {
146
+ return function stepMarker(text, docs) {
147
+ const ctx = getContext();
148
+ const step = {
149
+ id: `step-${ctx.stepCounter++}`,
150
+ keyword,
151
+ text,
152
+ docs: docs ? convertStoryDocsToEntries(docs) : []
153
+ };
154
+ ctx.meta.steps.push(step);
155
+ ctx.currentStep = step;
156
+ syncMetaToTask();
157
+ };
158
+ }
159
+ function note(text) {
160
+ const ctx = getContext();
161
+ const entry = { kind: "note", text, phase: "runtime" };
162
+ if (ctx.currentStep) {
163
+ ctx.currentStep.docs ??= [];
164
+ ctx.currentStep.docs.push(entry);
165
+ } else {
166
+ ctx.meta.docs ??= [];
167
+ ctx.meta.docs.push(entry);
168
+ }
169
+ }
170
+ function attachDoc(entry) {
171
+ const ctx = getContext();
172
+ if (ctx.currentStep) {
173
+ ctx.currentStep.docs ??= [];
174
+ ctx.currentStep.docs.push(entry);
175
+ } else {
176
+ ctx.meta.docs ??= [];
177
+ ctx.meta.docs.push(entry);
178
+ }
179
+ syncMetaToTask();
180
+ }
181
+ function kv(options) {
182
+ attachDoc({
183
+ kind: "kv",
184
+ label: options.label,
185
+ value: options.value,
186
+ phase: "runtime"
187
+ });
188
+ }
189
+ function json(options) {
190
+ const content = JSON.stringify(options.value, null, 2);
191
+ attachDoc({
192
+ kind: "code",
193
+ label: options.label,
194
+ content,
195
+ lang: "json",
196
+ phase: "runtime"
197
+ });
198
+ }
199
+ function code(options) {
200
+ attachDoc({
201
+ kind: "code",
202
+ label: options.label,
203
+ content: options.content,
204
+ lang: options.lang,
205
+ phase: "runtime"
206
+ });
207
+ }
208
+ function table(options) {
209
+ attachDoc({
210
+ kind: "table",
211
+ label: options.label,
212
+ columns: options.columns,
213
+ rows: options.rows,
214
+ phase: "runtime"
215
+ });
216
+ }
217
+ function link(options) {
218
+ attachDoc({
219
+ kind: "link",
220
+ label: options.label,
221
+ url: options.url,
222
+ phase: "runtime"
223
+ });
224
+ }
225
+ function section(options) {
226
+ attachDoc({
227
+ kind: "section",
228
+ title: options.title,
229
+ markdown: options.markdown,
230
+ phase: "runtime"
231
+ });
232
+ }
233
+ function mermaid(options) {
234
+ attachDoc({
235
+ kind: "mermaid",
236
+ code: options.code,
237
+ title: options.title,
238
+ phase: "runtime"
239
+ });
240
+ }
241
+ function screenshot(options) {
242
+ attachDoc({
243
+ kind: "screenshot",
244
+ path: options.path,
245
+ alt: options.alt,
246
+ phase: "runtime"
247
+ });
248
+ }
249
+ function tag(name) {
250
+ const names = Array.isArray(name) ? name : [name];
251
+ attachDoc({ kind: "tag", names, phase: "runtime" });
252
+ }
253
+ function custom(options) {
254
+ attachDoc({
255
+ kind: "custom",
256
+ type: options.type,
257
+ data: options.data,
258
+ phase: "runtime"
259
+ });
260
+ }
261
+ function attach(options) {
262
+ const ctx = getContext();
263
+ const stepIndex = ctx.currentStep ? ctx.meta.steps.indexOf(ctx.currentStep) : void 0;
264
+ ctx.attachments.push({
265
+ ...options,
266
+ stepIndex: stepIndex !== void 0 && stepIndex >= 0 ? stepIndex : void 0,
267
+ stepId: ctx.currentStep?.id
268
+ });
269
+ if (ctx.taskMeta) {
270
+ ctx.taskMeta.storyAttachments = ctx.attachments;
271
+ }
272
+ }
273
+ function startTimer() {
274
+ const ctx = getContext();
275
+ const token = ctx.timerCounter++;
276
+ const stepIndex = ctx.currentStep ? ctx.meta.steps.indexOf(ctx.currentStep) : void 0;
277
+ ctx.activeTimers.set(token, {
278
+ start: performance.now(),
279
+ stepIndex: stepIndex !== void 0 && stepIndex >= 0 ? stepIndex : void 0,
280
+ stepId: ctx.currentStep?.id,
281
+ consumed: false
282
+ });
283
+ return token;
284
+ }
285
+ function endTimer(token) {
286
+ const ctx = getContext();
287
+ const entry = ctx.activeTimers.get(token);
288
+ if (!entry || entry.consumed) return;
289
+ entry.consumed = true;
290
+ const durationMs = performance.now() - entry.start;
291
+ let step;
292
+ if (entry.stepId) {
293
+ step = ctx.meta.steps.find((s) => s.id === entry.stepId);
294
+ }
295
+ if (!step && entry.stepIndex !== void 0) {
296
+ step = ctx.meta.steps[entry.stepIndex];
297
+ }
298
+ if (step) {
299
+ step.durationMs = durationMs;
300
+ syncMetaToTask();
301
+ }
302
+ }
303
+ function fn(keyword, text, body) {
304
+ const ctx = getContext();
305
+ const step = {
306
+ id: `step-${ctx.stepCounter++}`,
307
+ keyword,
308
+ text,
309
+ docs: [],
310
+ wrapped: true
311
+ };
312
+ ctx.meta.steps.push(step);
313
+ ctx.currentStep = step;
314
+ syncMetaToTask();
315
+ const start = performance.now();
316
+ try {
317
+ const result = body();
318
+ if (result instanceof Promise) {
319
+ return result.then(
320
+ (val) => {
321
+ step.durationMs = performance.now() - start;
322
+ syncMetaToTask();
323
+ return val;
324
+ },
325
+ (err) => {
326
+ step.durationMs = performance.now() - start;
327
+ syncMetaToTask();
328
+ throw err;
329
+ }
330
+ );
331
+ }
332
+ step.durationMs = performance.now() - start;
333
+ syncMetaToTask();
334
+ return result;
335
+ } catch (err) {
336
+ step.durationMs = performance.now() - start;
337
+ syncMetaToTask();
338
+ throw err;
339
+ }
340
+ }
341
+ function storyExpect(text, body) {
342
+ return fn("Then", text, body);
343
+ }
344
+ var story = {
345
+ // Core
346
+ init,
347
+ // BDD step markers
348
+ given: createStepMarker("Given"),
349
+ when: createStepMarker("When"),
350
+ then: createStepMarker("Then"),
351
+ and: createStepMarker("And"),
352
+ but: createStepMarker("But"),
353
+ // AAA pattern aliases
354
+ arrange: createStepMarker("Given"),
355
+ act: createStepMarker("When"),
356
+ assert: createStepMarker("Then"),
357
+ // Additional aliases
358
+ setup: createStepMarker("Given"),
359
+ context: createStepMarker("Given"),
360
+ execute: createStepMarker("When"),
361
+ action: createStepMarker("When"),
362
+ verify: createStepMarker("Then"),
363
+ // Standalone doc methods
364
+ note,
365
+ kv,
366
+ json,
367
+ code,
368
+ table,
369
+ link,
370
+ section,
371
+ mermaid,
372
+ screenshot,
373
+ tag,
374
+ custom,
375
+ // Attachments
376
+ attach,
377
+ // Step wrappers
378
+ fn,
379
+ expect: storyExpect,
380
+ // Step timing
381
+ startTimer,
382
+ endTimer
383
+ };
384
+
385
+ // src/types.ts
386
+ import { STORY_META_KEY } from "executable-stories-formatters";
387
+
388
+ // src/index.ts
389
+ var STORY_REPORTER_GUARD_MSG = 'Do not import StoryReporter from "executable-stories-vitest". In vitest.config, import it from "executable-stories-vitest/reporter".';
390
+ var StoryReporter = class {
391
+ static __isGuard = true;
392
+ constructor() {
393
+ throw new Error(STORY_REPORTER_GUARD_MSG);
394
+ }
395
+ };
396
+ export {
397
+ STORY_META_KEY,
398
+ StoryReporter,
399
+ story
400
+ };
401
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/story-api.ts","../src/types.ts","../src/index.ts"],"sourcesContent":["/**\n * story.* API for executable-stories-vitest.\n *\n * Uses native Vitest describe/it/test with opt-in documentation:\n *\n * @example\n * ```ts\n * import { describe, it, expect } from 'vitest';\n * import { story } from 'executable-stories-vitest';\n *\n * describe('Calculator', () => {\n * it('adds two numbers', ({ task }) => {\n * story.init(task);\n *\n * story.given('two numbers 5 and 3');\n * const a = 5;\n * const 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 DocEntry,\n StepKeyword,\n StoryDocs,\n StoryMeta,\n StoryOptions,\n StoryStep,\n VitestSuite,\n} from './types';\n\n// ============================================================================\n// Task Interface (compatible with Vitest's actual task type)\n// ============================================================================\n\n/**\n * Minimal task interface compatible with Vitest's Test type.\n * The meta property accepts any object type to be compatible with Vitest's TaskMeta.\n */\ninterface TaskLike {\n name: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n meta: any;\n suite?: VitestSuite;\n file?: { name?: string };\n}\n\n// ============================================================================\n// Story Context\n// ============================================================================\n\n/** Attachment options for story.attach() */\nexport interface AttachmentOptions {\n name: string;\n mediaType: string;\n path?: string;\n body?: string;\n encoding?: \"BASE64\" | \"IDENTITY\";\n charset?: string;\n fileName?: string;\n}\n\n/** Internal: attachment with step scope */\ninterface ScopedAttachment extends AttachmentOptions {\n stepIndex?: number;\n stepId?: string;\n}\n\n/** Internal timer entry */\ninterface TimerEntry {\n start: number;\n stepIndex?: number;\n stepId?: string;\n consumed: boolean;\n}\n\ninterface StoryContext {\n /** The story metadata being built */\n meta: StoryMeta;\n /** The current step (for attaching docs) */\n currentStep: StoryStep | null;\n /** Reference to task.meta for updates */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n taskMeta: any;\n /** Deterministic step counter (resets per test case) */\n stepCounter: number;\n /** Collected attachments with step scope */\n attachments: ScopedAttachment[];\n /** Active timers keyed by token */\n activeTimers: Map<number, TimerEntry>;\n /** Monotonic timer token counter */\n timerCounter: number;\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(task) must be called first. Use: it('name', ({ task }) => { story.init(task); ... });\",\n );\n }\n return activeContext;\n}\n\n/** Re-attach current meta to task.meta.story so reporter sees steps and docs (e.g. story.note). */\nfunction syncMetaToTask(): void {\n if (activeContext?.taskMeta) {\n activeContext.taskMeta.story = activeContext.meta;\n }\n}\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\n/**\n * Check if a name looks like a file path (to filter out from suite paths).\n */\nfunction looksLikeFilePath(name: string): boolean {\n if (name.includes('/') || name.includes('\\\\')) return true;\n if (name.includes('.spec.') || name.includes('.test.')) return true;\n if (/\\.(spec|test)\\.(ts|js|mjs|cjs)$/.test(name)) return true;\n if (/\\.(ts|js|mjs|cjs)$/.test(name)) return true;\n return false;\n}\n\n/**\n * Extract the suite path (parent describe names) from a Vitest task object.\n */\nfunction extractSuitePath(task: TaskLike): string[] | undefined {\n const path: string[] = [];\n const fileName = task.file?.name;\n let current: VitestSuite | undefined = task.suite;\n\n while (current) {\n const name = current.name;\n if (\n name &&\n name.trim() !== '' &&\n name !== '<root>' &&\n name !== fileName &&\n !looksLikeFilePath(name)\n ) {\n path.unshift(name);\n }\n current = current.suite;\n }\n\n return path.length > 0 ? path : undefined;\n}\n\n/**\n * Normalize ticket option to array format.\n */\nfunction normalizeTickets(\n ticket: string | string[] | undefined,\n): string[] | undefined {\n if (!ticket) return undefined;\n return Array.isArray(ticket) ? ticket : [ticket];\n}\n\n/**\n * Convert StoryDocs inline options to DocEntry array.\n * Matches the standalone DocApi method signatures.\n */\nfunction convertStoryDocsToEntries(docs: StoryDocs): DocEntry[] {\n const entries: DocEntry[] = [];\n\n // note(text)\n if (docs.note) {\n entries.push({ kind: 'note', text: docs.note, phase: 'runtime' });\n }\n\n // tag(name | names)\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\n // kv(label, value) - multiple pairs via Record\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\n // code(label, content, lang?)\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\n // json(label, value)\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\n // table(label, columns, rows)\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\n // link(label, url)\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\n // section(title, markdown)\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\n // mermaid(code, title?)\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\n // screenshot(path, alt?)\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\n // custom(type, data)\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\n// ============================================================================\n// story.init()\n// ============================================================================\n\n/**\n * Initialize a story for the current test.\n * Must be called at the start of each test that wants documentation.\n *\n * @param task - The Vitest task object from ({ task }) => { ... }\n * @param options - Optional story configuration (tags, ticket, meta)\n *\n * @example\n * ```ts\n * it('adds two numbers', ({ task }) => {\n * story.init(task);\n * // ... rest of test\n * });\n *\n * // With options:\n * it('admin deletes user', ({ task }) => {\n * story.init(task, {\n * tags: ['admin', 'destructive'],\n * ticket: 'JIRA-456'\n * });\n * });\n * ```\n */\nfunction init(task: TaskLike, options?: StoryOptions): void {\n const meta: StoryMeta = {\n scenario: task.name,\n steps: [],\n suitePath: extractSuitePath(task),\n tags: options?.tags,\n tickets: normalizeTickets(options?.ticket),\n meta: options?.meta,\n sourceOrder: sourceOrderCounter++,\n };\n\n // Attach to task.meta so reporter can find it\n task.meta.story = meta;\n\n // Set active context\n activeContext = {\n meta,\n currentStep: null,\n taskMeta: task.meta,\n stepCounter: 0,\n attachments: [],\n activeTimers: new Map(),\n timerCounter: 0,\n };\n}\n\n// ============================================================================\n// Step Markers\n// ============================================================================\n\n/**\n * Create a step marker function for a given keyword.\n */\nfunction createStepMarker(keyword: StepKeyword) {\n return function stepMarker(text: string, docs?: StoryDocs): void {\n const ctx = getContext();\n\n const step: StoryStep = {\n id: `step-${ctx.stepCounter++}`,\n keyword,\n text,\n docs: docs ? convertStoryDocsToEntries(docs) : [],\n };\n\n ctx.meta.steps.push(step);\n ctx.currentStep = step;\n syncMetaToTask();\n };\n}\n\n// ============================================================================\n// Doc Methods (Standalone)\n// ============================================================================\n\n/**\n * Add a free-text note to the current step or story-level if before any step.\n */\nfunction note(text: string): void {\n const ctx = getContext();\n const entry: DocEntry = { kind: 'note', text, phase: 'runtime' };\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}\n\n// ============================================================================\n// Doc Method Types (shared between standalone and inline)\n// ============================================================================\n\n/** Options for kv() - key-value pair */\ninterface KvOptions {\n label: string;\n value: unknown;\n}\n\n/** Options for json() - JSON code block */\ninterface JsonOptions {\n label: string;\n value: unknown;\n}\n\n/** Options for code() - code block with optional language */\ninterface CodeOptions {\n label: string;\n content: string;\n lang?: string;\n}\n\n/** Options for table() - markdown table */\ninterface TableOptions {\n label: string;\n columns: string[];\n rows: string[][];\n}\n\n/** Options for link() - hyperlink */\ninterface LinkOptions {\n label: string;\n url: string;\n}\n\n/** Options for section() - titled markdown section */\ninterface SectionOptions {\n title: string;\n markdown: string;\n}\n\n/** Options for mermaid() - Mermaid diagram */\ninterface MermaidOptions {\n code: string;\n title?: string;\n}\n\n/** Options for screenshot() - screenshot reference */\ninterface ScreenshotOptions {\n path: string;\n alt?: string;\n}\n\n/** Options for custom() - custom doc entry */\ninterface CustomOptions {\n type: string;\n data: unknown;\n}\n\n// ============================================================================\n// Helper to attach doc entry to current step or story-level\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 syncMetaToTask();\n}\n\n// ============================================================================\n// Doc Methods (Standalone) - same shape as inline docs\n// ============================================================================\n\n/**\n * Add a key-value pair to the current step or story-level.\n * @example story.kv({ label: 'Payment ID', value: 'pay_123' })\n */\nfunction kv(options: KvOptions): void {\n attachDoc({\n kind: 'kv',\n label: options.label,\n value: options.value,\n phase: 'runtime',\n });\n}\n\n/**\n * Add a JSON code block to the current step or story-level.\n * @example story.json({ label: 'Order', value: { id: 123 } })\n */\nfunction json(options: JsonOptions): void {\n const content = JSON.stringify(options.value, null, 2);\n attachDoc({\n kind: 'code',\n label: options.label,\n content,\n lang: 'json',\n phase: 'runtime',\n });\n}\n\n/**\n * Add a code block with optional language to the current step or story-level.\n * @example story.code({ label: 'Config', content: 'port: 3000', lang: 'yaml' })\n */\nfunction code(options: CodeOptions): void {\n attachDoc({\n kind: 'code',\n label: options.label,\n content: options.content,\n lang: options.lang,\n phase: 'runtime',\n });\n}\n\n/**\n * Add a markdown table to the current step or story-level.\n * @example story.table({ label: 'Users', columns: ['Name', 'Role'], rows: [['Alice', 'Admin']] })\n */\nfunction table(options: TableOptions): void {\n attachDoc({\n kind: 'table',\n label: options.label,\n columns: options.columns,\n rows: options.rows,\n phase: 'runtime',\n });\n}\n\n/**\n * Add a hyperlink to the current step or story-level.\n * @example story.link({ label: 'API Docs', url: 'https://docs.example.com' })\n */\nfunction link(options: LinkOptions): void {\n attachDoc({\n kind: 'link',\n label: options.label,\n url: options.url,\n phase: 'runtime',\n });\n}\n\n/**\n * Add a titled section with markdown content to the current step or story-level.\n * @example story.section({ title: 'Details', markdown: 'This is **important**' })\n */\nfunction section(options: SectionOptions): void {\n attachDoc({\n kind: 'section',\n title: options.title,\n markdown: options.markdown,\n phase: 'runtime',\n });\n}\n\n/**\n * Add a Mermaid diagram to the current step or story-level.\n * @example story.mermaid({ code: 'graph LR; A-->B', title: 'Flow' })\n */\nfunction mermaid(options: MermaidOptions): void {\n attachDoc({\n kind: 'mermaid',\n code: options.code,\n title: options.title,\n phase: 'runtime',\n });\n}\n\n/**\n * Add a screenshot reference to the current step or story-level.\n * @example story.screenshot({ path: '/screenshots/result.png', alt: 'Final result' })\n */\nfunction screenshot(options: ScreenshotOptions): void {\n attachDoc({\n kind: 'screenshot',\n path: options.path,\n alt: options.alt,\n phase: 'runtime',\n });\n}\n\n/**\n * Add tag(s) to the current step or story-level.\n * @example story.tag('admin') or story.tag(['admin', 'security'])\n */\nfunction tag(name: string | string[]): void {\n const names = Array.isArray(name) ? name : [name];\n attachDoc({ kind: 'tag', names, phase: 'runtime' });\n}\n\n/**\n * Add a custom documentation entry for use with custom renderers.\n * @example story.custom({ type: 'myType', data: { foo: 'bar' } })\n */\nfunction custom(options: CustomOptions): void {\n attachDoc({\n kind: 'custom',\n type: options.type,\n data: options.data,\n phase: 'runtime',\n });\n}\n\n// ============================================================================\n// Attachments\n// ============================================================================\n\n/**\n * Attach a file or inline content to the current step or test case.\n * @example story.attach({ name: 'screenshot', mediaType: 'image/png', path: '/tmp/screenshot.png' })\n */\nfunction 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 // Store attachments on task.meta so reporter can read them\n if (ctx.taskMeta) {\n ctx.taskMeta.storyAttachments = ctx.attachments;\n }\n}\n\n// ============================================================================\n// Step Timing\n// ============================================================================\n\n/**\n * Start a timer for the current step. Returns a token to pass to endTimer().\n */\nfunction 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/**\n * End a timer and record duration on the step that was active when startTimer() was called.\n */\nfunction 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 syncMetaToTask();\n }\n}\n\n// ============================================================================\n// Step Wrappers: story.fn() and story.expect()\n// ============================================================================\n\n/**\n * Wrap a function body as a step. Records the step with timing and `wrapped: true`.\n * Supports both sync and async functions. Returns whatever the function returns.\n *\n * @param keyword - The BDD keyword (Given, When, Then, And, But)\n * @param text - Step description\n * @param body - The function to execute\n * @returns The return value of body (or a Promise of it if body is async)\n *\n * @example\n * ```ts\n * const data = story.fn('Given', 'setup data', () => ({ a: 5, b: 3 }));\n * const result = await story.fn('When', 'call API', async () => fetch('/api'));\n * ```\n */\nfunction fn<T>(keyword: StepKeyword, text: string, body: () => T): T {\n const ctx = getContext();\n\n const step: StoryStep = {\n id: `step-${ctx.stepCounter++}`,\n keyword,\n text,\n docs: [],\n wrapped: true,\n };\n\n ctx.meta.steps.push(step);\n ctx.currentStep = step;\n syncMetaToTask();\n\n const start = performance.now();\n\n try {\n const result = body();\n\n // Handle async functions\n if (result instanceof Promise) {\n return result.then(\n (val) => {\n step.durationMs = performance.now() - start;\n syncMetaToTask();\n return val;\n },\n (err) => {\n step.durationMs = performance.now() - start;\n syncMetaToTask();\n throw err;\n },\n ) as T;\n }\n\n step.durationMs = performance.now() - start;\n syncMetaToTask();\n return result;\n } catch (err) {\n step.durationMs = performance.now() - start;\n syncMetaToTask();\n throw err;\n }\n}\n\n/**\n * Wrap an assertion as a Then step. Shorthand for `story.fn('Then', text, body)`.\n *\n * @param text - Step description\n * @param body - The assertion function to execute\n *\n * @example\n * ```ts\n * story.expect('the result is 8', () => { expect(result).toBe(8); });\n * await story.expect('async check', async () => { ... });\n * ```\n */\nfunction storyExpect<T>(text: string, body: () => T): T {\n return fn('Then', text, body);\n}\n\n// ============================================================================\n// Export story object\n// ============================================================================\n\n/**\n * The main story API object.\n *\n * Use with native Vitest describe/it/test for full IDE support:\n *\n * @example\n * ```ts\n * import { describe, it, expect } from 'vitest';\n * import { story } from 'executable-stories-vitest';\n *\n * describe('Calculator', () => {\n * it('adds two numbers', ({ task }) => {\n * story.init(task);\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 */\nexport const story = {\n // Core\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,\n kv,\n json,\n code,\n table,\n link,\n section,\n mermaid,\n screenshot,\n tag,\n custom,\n\n // Attachments\n attach,\n\n // Step wrappers\n fn,\n expect: storyExpect,\n\n // Step timing\n startTimer,\n endTimer,\n};\n\nexport type Story = typeof story;\n","/**\n * Type definitions for executable-stories-vitest.\n *\n * Shared story types (StepKeyword, DocEntry, StoryStep, StoryMeta, etc.)\n * are imported from executable-stories-formatters — the single source of truth.\n * This module re-exports them and adds Vitest-specific types.\n */\n\n// Re-export shared story types from formatters\nexport type {\n StepKeyword,\n StepMode,\n DocPhase,\n DocEntry,\n StoryStep,\n StoryMeta,\n} from 'executable-stories-formatters';\n\nexport { STORY_META_KEY } from 'executable-stories-formatters';\n\n// ============================================================================\n// Vitest-specific Types\n// ============================================================================\n\n/**\n * Inline documentation options for step markers.\n * Pass to story.given(), story.when(), story.then() as second argument.\n *\n * @example\n * ```ts\n * story.given('valid credentials', {\n * json: { label: 'Credentials', value: { email: 'test@example.com', password: '***' } },\n * note: 'Password is masked for security'\n * });\n * ```\n */\nexport interface StoryDocs {\n /** Add a free-text note */\n note?: string;\n /** Add tag(s) for categorization */\n tag?: string | string[];\n /** Add key-value pairs */\n kv?: Record<string, unknown>;\n /** Add a code block with label and optional language */\n code?: { label: string; content: string; lang?: string };\n /** Add a JSON data block with label */\n json?: { label: string; value: unknown };\n /** Add a markdown table with label */\n table?: { label: string; columns: string[]; rows: string[][] };\n /** Add a hyperlink */\n link?: { label: string; url: string };\n /** Add a titled section with markdown content */\n section?: { title: string; markdown: string };\n /** Add a Mermaid diagram with optional title */\n mermaid?: { code: string; title?: string };\n /** Add a screenshot reference */\n screenshot?: { path: string; alt?: string };\n /** Add a custom documentation entry */\n custom?: { type: string; data: unknown };\n}\n\n/**\n * Options for configuring a story via story.init().\n *\n * @example\n * ```ts\n * it('admin deletes user', ({ task }) => {\n * story.init(task, {\n * tags: ['admin', 'destructive'],\n * ticket: 'JIRA-456'\n * });\n * });\n * ```\n */\nexport interface StoryOptions {\n /** Tags for filtering and categorizing stories */\n tags?: string[];\n /** Ticket/issue reference(s) for requirements traceability */\n ticket?: string | string[];\n /** Arbitrary user-defined metadata */\n meta?: Record<string, unknown>;\n}\n\n// ============================================================================\n// Vitest Task Type (minimal interface)\n// ============================================================================\n\n/** Minimal Vitest suite interface for suite path extraction */\nexport interface VitestSuite {\n /** Suite name */\n name?: string;\n /** Parent suite (optional) */\n suite?: VitestSuite;\n}\n\n/**\n * Minimal Vitest task interface for story.init().\n * This is the { task } from it('name', ({ task }) => { ... }).\n *\n * Uses generic type parameter to be compatible with Vitest's actual TaskMeta type.\n */\nexport interface VitestTask<TMeta = Record<string, unknown>> {\n /** The test/task name */\n name: string;\n /** Task metadata object where we store story data */\n meta: TMeta;\n /** Parent suite (optional) */\n suite?: VitestSuite;\n /** The test file (optional) */\n file?: { name?: string };\n}\n","/**\n * executable-stories-vitest: Native Vitest story/given/when/then with Markdown doc generation.\n *\n * Uses native Vitest describe/it/test for full IDE support:\n *\n * @example\n * ```ts\n * import { describe, it, expect } from 'vitest';\n * import { story } from 'executable-stories-vitest';\n *\n * describe('Calculator', () => {\n * it('adds two numbers', ({ task }) => {\n * story.init(task);\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 * In vitest.config, import StoryReporter from \"executable-stories-vitest/reporter\":\n *\n * @example\n * ```ts\n * import { defineConfig } from \"vitest/config\";\n * import { StoryReporter } from \"executable-stories-vitest/reporter\";\n *\n * export default defineConfig({\n * test: {\n * reporters: [\"default\", new StoryReporter()],\n * },\n * });\n * ```\n */\n\n// Core API\nexport { story, type Story } from './story-api';\n\n// Types for consumers\nexport type {\n StoryMeta,\n StoryStep,\n DocEntry,\n StepKeyword,\n StepMode,\n DocPhase,\n StoryDocs,\n StoryOptions,\n VitestTask,\n VitestSuite,\n} from './types';\n\nexport { STORY_META_KEY } from './types';\n\n// Reporter types (actual reporter is in /reporter subpath)\nexport type {\n StoryReporterOptions,\n OutputFormat,\n OutputMode,\n ColocatedStyle,\n OutputRule,\n FormatterOptions,\n} from './reporter';\n\nconst STORY_REPORTER_GUARD_MSG =\n 'Do not import StoryReporter from \"executable-stories-vitest\". In vitest.config, import it from \"executable-stories-vitest/reporter\".';\n\n/** @internal Guard: throws if used. Import StoryReporter from \"executable-stories-vitest/reporter\" in vitest.config. */\nexport class StoryReporter {\n static __isGuard = true;\n constructor() {\n throw new Error(STORY_REPORTER_GUARD_MSG);\n }\n}\n"],"mappings":";AAsGA,IAAI,gBAAqC;AAGzC,IAAI,qBAAqB;AAKzB,SAAS,aAA2B;AAClC,MAAI,CAAC,eAAe;AAClB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;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