@digital-commons-official/codeceptjs-storyboard 1.0.2 → 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/README.md CHANGED
@@ -3,10 +3,10 @@
3
3
 
4
4
  [![pipeline status](https://gitlab.com/digital-commons/software/libraries/npm/codeceptjs-storyboard/badges/main/pipeline.svg)](https://gitlab.com/digital-commons/software/libraries/npm/codeceptjs-storyboard/-/commits/main)
5
5
 
6
- A [CodeceptJS](https://codecept.io) plugin that turns one Gherkin scenario into one human-readable SVG storyboard, straight from the real screenshots the test captures.
6
+ A [CodeceptJS](https://codecept.io) plugin that turns one Gherkin scenario into one human-readable storyboard, straight from the real screenshots the test captures. Markdown is the default; select SVG explicitly when you want a self-contained picture.
7
7
 
8
8
  ONE Gherkin sentence = ONE card = ONE pixel baseline, asserted inside its step at `tolerance: 0`: a visual regression fails on the exact sentence whose image drifted.
9
- When the scenario ends the plugin assembles the whole story into one SVG: the frames stay bitmap, but every caption, note and reproduce-command around them is real selectable text you can copy from the SVG (Chromium/Safari).
9
+ When the scenario ends, Markdown shows screenshots side by side with readable captions, notes and copyable commands. It links the original PNGs instead of embedding their bytes, so reviewers can open the file directly in GitLab. SVG embeds the screenshots and retains selectable text around them (Chromium/Safari).
10
10
 
11
11
  ## Installation 📦
12
12
 
@@ -28,13 +28,14 @@ The browser suite installs the actual packed package into six fresh projects:
28
28
 
29
29
  | Node.js | CodeceptJS | VisualHelper |
30
30
  |---------------------------|------------|--------------|
31
- | 22.19.0, 24.21.0, 26.10.0 | 4.2.0 | 1.3.0 |
32
- | 22.19.0, 24.21.0, 26.10.0 | 4.2.0 | 2.0.3 |
31
+ | 22.23.4, 24.22.1, 26.12.1 | 4.2.0 | 1.3.0 |
32
+ | 22.23.4, 24.22.1, 26.12.1 | 4.2.0 | 2.0.3 |
33
33
 
34
34
  Each project imports its own four packages, passes `npm audit`, records one
35
35
  English journey and three French Rule cases, then reruns with strict pixel
36
36
  comparison. All fourteen baseline hashes must stay unchanged and match across
37
- the six combinations. The real gallery must link all four journeys.
37
+ the six combinations. Each project also runs the default Markdown format against
38
+ those same hashes and checks all four Markdown gallery links.
38
39
 
39
40
  Node 18 is rejected with `--engine-strict`; CodeceptJS 4.0 is rejected with
40
41
  `--strict-peer-deps`. Older CodeceptJS 4.0 consumers also fail the security audit.
@@ -43,8 +44,11 @@ versions exercised in CI. Use the same Playwright browser and fonts when
43
44
  comparing pictures across machines.
44
45
 
45
46
  These installation tests use `npm pack` and real npm commands. They do not
46
- authenticate a publication to the registry; the release job and npm provenance
47
- provide that separate proof.
47
+ authenticate a publication to the registry; only a successful release job
48
+ provides that separate proof. Releases use GitLab OIDC authentication without
49
+ a stored npm token and run only on the protected default branch. npm provenance
50
+ is explicitly disabled because npm rejects attestations from self-hosted
51
+ runners, so these releases do not include an npm provenance attestation.
48
52
 
49
53
  ## Public API and compatibility
50
54
 
@@ -57,10 +61,10 @@ Their signatures are defined in [src/index.d.ts](src/index.d.ts).
57
61
  | `capturePageFrame`, `captureElementFrame`, `frameOutputPath` | Capture a real viewport or element and return its frame path. |
58
62
  | `addStoryboardFrame`, `assertOrUpdateBaseline` | Assert pixels strictly; only `TASK_E2E_UPDATE_BASELINES=1` outside CI records baselines. |
59
63
  | `begin`, `baseDir`, `panel`, `frame`, `annotate`, `panels` | Manage a scenario's cards; `frame` attaches an image without asserting it. |
60
- | `parseScenarioLines`, `render` | Read the original Gherkin sentences and render their SVG. |
64
+ | `parseScenarioLines`, `render` | Read the original Gherkin sentences and render Markdown or SVG. |
61
65
  | `tryTo` | Re-export the CodeceptJS effect for an optional action. |
62
66
 
63
- The supported plugin options are `theme` and `replayCommand`; CodeceptJS owns
67
+ The supported plugin options are `format`, `theme`, `markdown` and `replayCommand`; CodeceptJS owns
64
68
  `require` and `enabled`. From 1.0.0, compatible releases preserve this public
65
69
  API and the documented baseline recording behaviour. Removing a public
66
70
  function, changing its required arguments or raising a supported minimum
@@ -112,17 +116,107 @@ exports.config = {
112
116
  }
113
117
  ```
114
118
 
115
- Nothing configures paths: everything is derived from the feature file location.
116
- Frames land in `_output/storyboard-frames/`, baselines in `screenshots/base/<feature-dir>/<scenario-tag>/`, the committed SVG in `storyboards/<feature-dir>/<scenario-tag>.svg`.
117
- A scenario that never calls `addStoryboardFrame` renders no SVG, so plain Gherkin tests are left untouched.
119
+ ### Choose one format
118
120
 
119
- When the run ends, open `_output/index.html` to browse its storyboards. The page groups scenarios by feature directory, puts failed groups and scenarios first, and shows the failed sentence with its replay command. Links open the actual SVGs.
121
+ Omit `format` or set `format: 'markdown'` for Markdown. Set `format: 'svg'` for SVG:
120
122
 
121
- A filtered run lists only the scenarios it ran. In baseline-update mode, `storyboards/index.html` lists the passing scenarios from that update; failed scenarios never replace reviewed storyboards. Run the full suite in update mode to rebuild the complete reviewed gallery.
123
+ ```javascript
124
+ storyboard: {
125
+ require: '@digital-commons-official/codeceptjs-storyboard',
126
+ enabled: true,
127
+ format: 'svg'
128
+ }
129
+ ```
130
+
131
+ Exactly one format is generated per run. Arrays, `both`, `md`, `null` and other values are rejected. Markdown is a breaking default change: add `format: 'svg'` to retain the earlier SVG files and HTML gallery. Existing standalone `render('board.svg', options)` calls still render SVG.
132
+
133
+ Paths are derived from the feature file location. Frames land in `_output/storyboard-frames/` and baselines in `screenshots/base/<feature-dir>/<scenario-tag>/`.
134
+
135
+ | Output | Markdown (default) | SVG |
136
+ |---------------------|-----------------------------------------------|------------------------------------------------|
137
+ | Current scenario | `_output/<feature-dir>/<scenario-tag>.md` | `_output/<feature-dir>/<scenario-tag>.svg` |
138
+ | Reviewed scenario | `storyboards/<feature-dir>/<scenario-tag>.md` | `storyboards/<feature-dir>/<scenario-tag>.svg` |
139
+ | Current-run gallery | `_output/index.md` | `_output/index.html` |
140
+ | Reviewed gallery | `storyboards/index.md` | `storyboards/index.html` |
141
+
142
+ A scenario without captured frames produces no storyboard, so plain Gherkin tests are left untouched.
143
+
144
+ When the run ends, open the selected gallery to browse its storyboards. It groups scenarios by feature directory, puts failed groups and scenarios first, and shows the failed sentence with its replay command. Links open the selected format.
145
+
146
+ A filtered run lists only the scenarios it ran. In baseline-update mode, the reviewed gallery lists the passing scenarios from that update; failed scenarios never replace reviewed storyboards. Run the full suite in update mode to rebuild the complete reviewed gallery. Files from earlier runs or another format are not deleted or added to the current gallery.
147
+
148
+ ### Read Markdown on a branch or merge request
149
+
150
+ Commit the generated files under `storyboards/` together with their reviewed PNGs under `screenshots/base/`.
151
+ Open the Markdown file on the branch being reviewed. Relative image links use that same revision; after
152
+ merging, opening the file on the target branch uses the merged images. No branch name, GitLab hostname or
153
+ token is stored in the document. A URL to a deleted source branch is not redirected automatically.
154
+
155
+ For example, `storyboards/login/sign-in.md` can link to `../../screenshots/base/login/sign-in/form.png`. The paths also work in a local Markdown viewer with the repository layout intact. This applies to repository files; pasting their contents into an MR description uses a different link context.
156
+
157
+ Runtime Markdown references actual captures and, for a failure, the expected/diff/actual images. Keep `_output/` and `screenshots/` in their original relative layout when downloading reports. A Markdown file alone does not include its images. SVG is the self-contained option. Repository rendering does not imply that GitLab's CI artifact viewer previews Markdown.
158
+
159
+ Markdown keeps chapters, sentence order, annotations, multilingual keywords and failure information.
160
+ The report starts with its recorded outcome and frame/step counts, followed by links to chapters,
161
+ the result and replay information. A standalone render without an explicit outcome says
162
+ "Outcome not recorded"; it does not infer success from the absence of a visual failure.
163
+
164
+ Local coloured banners separate chapters, with full selectable headings beneath them. A report without
165
+ chapters gets a journey banner. Screenshots sit in two equal-width columns by default. Each card keeps
166
+ its title, image, note and copyable command together. Each pair has its own table so GitLab does not put
167
+ an entire chapter inside one scrolling region. Commands fold within their card; replay and source
168
+ details fold at the end. A failed comparison keeps Expected / Diff / Actual and unavailable-image
169
+ labels visible, regardless of the details setting.
170
+
171
+ ### Markdown colours and layout
172
+
173
+ Configure presentation directly on the plugin; no CSS file is needed:
174
+
175
+ ```javascript
176
+ storyboard: {
177
+ require: '@digital-commons-official/codeceptjs-storyboard',
178
+ enabled: true,
179
+ markdown: {
180
+ colors: {
181
+ banner: '#155e50',
182
+ bannerText: '#ffffff',
183
+ accent: '#559b84'
184
+ },
185
+ columns: 2,
186
+ tableOfContents: true,
187
+ technicalDetails: 'collapsed'
188
+ }
189
+ }
190
+ ```
191
+
192
+ The example shows the defaults. Set `columns: 1` for full-width cards, especially when reading on
193
+ narrow screens. GitLab tables do not automatically stack like a responsive HTML grid.
194
+ Set `technicalDetails: 'expanded'` to open commands and replay/source details, or
195
+ `tableOfContents: false` to omit navigation. Neither option removes evidence or notes.
196
+
197
+ Colours accept 3- or 6-digit hexadecimal values. If you change `banner` without supplying `bannerText`, the renderer
198
+ chooses light or dark text for contrast. An explicit text/background combination must have a contrast
199
+ ratio of at least 4.5:1. Invalid colours, unsupported options and invalid layout values raise a clear
200
+ error before the plugin registers listeners or the standalone renderer writes artifacts.
201
+
202
+ Generated banners live in an adjacent `_storyboard-assets/` directory and are named from their content.
203
+ **Commit these assets with the reviewed `.md` files and PNGs.** Keep that relative directory structure
204
+ when downloading runtime reports too. Repeated renders reuse the same asset names; unused older
205
+ assets are not automatically deleted. Banners are small decorations, not an additional full SVG report.
206
+ Long titles are abbreviated in the decoration but remain complete in the native Markdown heading.
207
+
208
+ The palette affects banner backgrounds, text and decorative accents. GitLab controls the page
209
+ background, fonts and native alert colours through the reader's preferences. Essential information
210
+ remains text even when images cannot load. The renderer never recolours screenshots, loads external
211
+ assets, or applies the SVG-only `theme` option to Markdown. Explicit `format: 'svg'` keeps its existing
212
+ theme behaviour and ignores Markdown presentation settings.
213
+
214
+ Standalone callers can use `render('report.md', { markdown: { columns: 1 }, outcome: 'passed' })`.
215
+ Only provide `outcome` when it is known; failure evidence always takes precedence over a passed value.
122
216
 
123
217
  ### Replay commands
124
218
 
125
- The gallery and SVG default to `npx codeceptjs run --steps --grep "{tag}"`.
219
+ The gallery and storyboard default to `npx codeceptjs run --steps --grep "{tag}"`.
126
220
  `{tag}` becomes the scenario's last tag. This command works in a standalone
127
221
  CodeceptJS project with a local installation and its default configuration file.
128
222
 
@@ -141,12 +235,13 @@ Use a unique scenario tag so the command selects the intended journey.
141
235
 
142
236
  ### Colours and fonts
143
237
 
144
- Set `theme` on the storyboard plugin to an object, a CSS file path, or an HTTP(S) URL:
238
+ In SVG mode, set `theme` on the storyboard plugin to an object, a CSS file path, or an HTTP(S) URL:
145
239
 
146
240
  ```javascript
147
241
  storyboard: {
148
242
  require: '@digital-commons-official/codeceptjs-storyboard',
149
243
  enabled: true,
244
+ format: 'svg',
150
245
  theme: './storyboard.css'
151
246
  // Or: theme: 'https://example.org/storyboard.css'
152
247
  // Or: theme: { bg: '#f6f8fb', text: '#192b3d', sans: 'Georgia, serif' }
@@ -183,9 +278,9 @@ Only these properties are read. Imports, external fonts and arbitrary CSS rules
183
278
 
184
279
  Attach structured comments to the sentence just below them. The feature file carries the story, the step file only drives and captures:
185
280
 
186
- - `# Chapter: Title` opens a full-width chapter band before that card.
281
+ - `# Chapter: Title` opens a section before that card (a full-width band in SVG).
187
282
  - `# Note: text` is the card's explanation: what to look at, why it matters. Repeat the line to stack paragraphs.
188
- - `# Copy: command` is the exact command shown one-click-copyable under the card.
283
+ - `# Copy: command` is the exact copyable command shown with the card.
189
284
 
190
285
  The scenario's LAST tag names the baseline directory and the replay command printed on the board.
191
286
 
@@ -221,7 +316,7 @@ storyboard.storyboardStep(Given, 'a fresh project with only a README on its main
221
316
 
222
317
  Set `# language: fr` (or another Cucumber dialect) on the first line of a feature file. Without this header, Gherkin uses English. Storyboards keep the source keywords, accents and scenario title, including keywords joined directly to the sentence. Register the translated sentences in your CodeceptJS step definitions.
223
318
 
224
- Background steps and outline examples appear in execution order. Each example row gets its own SVG and baseline directory, with an `-example-<line>` suffix. Repeated sentences keep their own annotations.
319
+ Background steps and outline examples appear in execution order. Each example row gets its own storyboard and baseline directory, with an `-example-<line>` suffix. Repeated sentences keep their own annotations.
225
320
 
226
321
  `# Chapter`, `# Note` and `# Copy` remain the annotation keys in every language; outline values are substituted in them too. Text inside doc strings and data tables does not become an extra card or annotation.
227
322
 
@@ -235,15 +330,15 @@ An empty selection fails clearly instead of succeeding with zero tests.
235
330
 
236
331
  The [multilingual storyboard](tests/e2e/storyboards/05-languages/storyboard-languages.svg) runs English, French and German examples and shows a real visual regression on a French sentence.
237
332
 
238
- The [rule storyboard](tests/e2e/storyboards/07-rules/storyboard-rules.svg) executes
333
+ The [rule storyboard](tests/e2e/storyboards/07-rules/storyboard-rules.md) executes
239
334
  two French outline examples and a second rule, checks both backgrounds and the
240
335
  tag filter, and proves the exact sentence of a deliberate visual regression.
241
336
 
242
337
  ### What you get
243
338
 
244
- - On every run the SVG of the scenario is written under `_output/<feature-dir>/<scenario-tag>.svg`.
245
- - On a failed run that SVG shows, in place of the drifted card, a red band with the expected image, the changed pixels and the actual image, each over its copyable path, then lists the sentences the run never reached.
246
- - In baseline-update mode the plugin asserts first and rewrites a baseline only when its assert fails, then rebuilds the committed SVG under `storyboards/` from the reviewed baselines:
339
+ - On every run the selected storyboard is written under `_output/<feature-dir>/<scenario-tag>.md` or `.svg`.
340
+ - On a failed run the storyboard shows the expected image, the changed pixels and the actual image with their paths, then lists the sentences the run never reached. SVG presents the comparison as a red band; Markdown uses a labelled table.
341
+ - In baseline-update mode the plugin asserts first and rewrites a baseline only when its assert fails, then rebuilds the reviewed storyboard under `storyboards/` from the reviewed baselines:
247
342
 
248
343
  ```bash
249
344
  TASK_E2E_UPDATE_BASELINES=1 npx codeceptjs run
@@ -255,19 +350,19 @@ by a human, which is why that mode throws when `CI` is set.
255
350
 
256
351
  ## API 📚
257
352
 
258
- | Function | Purpose |
259
- |-------------------------------------------------|--------------------------------------------------------------------------|
260
- | `storyboardStep(register, sentence, fn)` | Register a sentence literally through `Given`, `When` or `Then` |
261
- | `capturePageFrame(I, name)` | Full-viewport frame, returns the PNG path |
262
- | `captureElementFrame(I, name, selector)` | Element-cropped frame, returns the PNG path |
263
- | `addStoryboardFrame(I, png)` | Attach the frame to the open card and assert it at `tolerance: 0` |
264
- | `annotate({ note, copy })` | Runtime override of the open card's note and copyable command |
265
- | `assertOrUpdateBaseline(I, name)` | The assert-or-rewrite primitive `addStoryboardFrame` relies on |
266
- | `render(outFile, { imageDir, failure, theme })` | Write the SVG, optionally with a theme object |
267
- | `parseScenarioLines(featureFile, title)` | Every sentence of a scenario with its `# Chapter` / `# Note` / `# Copy` |
268
- | `begin`, `panel`, `frame`, `panels` | The board primitives the plugin drives (useful for standalone rendering) |
353
+ | Function | Purpose |
354
+ |------------------------------------------|--------------------------------------------------------------------------|
355
+ | `storyboardStep(register, sentence, fn)` | Register a sentence literally through `Given`, `When` or `Then` |
356
+ | `capturePageFrame(I, name)` | Full-viewport frame, returns the PNG path |
357
+ | `captureElementFrame(I, name, selector)` | Element-cropped frame, returns the PNG path |
358
+ | `addStoryboardFrame(I, png)` | Attach the frame to the open card and assert it at `tolerance: 0` |
359
+ | `annotate({ note, copy })` | Runtime override of the open card's note and copyable command |
360
+ | `assertOrUpdateBaseline(I, name)` | The assert-or-rewrite primitive `addStoryboardFrame` relies on |
361
+ | `render(outFile, options)` | Write Markdown for `.md` or SVG for `.svg`; theme applies only to SVG |
362
+ | `parseScenarioLines(featureFile, title)` | Every sentence of a scenario with its `# Chapter` / `# Note` / `# Copy` |
363
+ | `begin`, `panel`, `frame`, `panels` | The board primitives the plugin drives (useful for standalone rendering) |
269
364
 
270
- Type definitions ship in `src/index.d.ts`.
365
+ Type definitions ship in `src/index.d.ts`. Standalone rendering uses the output extension independently of plugin configuration and rejects other extensions.
271
366
 
272
367
  ## Development 🛠️
273
368
 
@@ -276,18 +371,32 @@ task build # install dependencies + build the e2e r
276
371
  task test # unit tests, then the e2e storyboard suite
277
372
  task project:test:storyboard # unit tests only (vitest)
278
373
  task project:test:storyboard:e2e # e2e storyboard suite only, inside the pinned Playwright runner
374
+ task project:test:storyboard:markdown # render the four selected review journeys as Markdown
375
+ task project:test:storyboard:svg # render the remaining review journeys as SVG
279
376
  task project:test:storyboard:e2e -- --grep "@storyboard-happy-path"
280
- TASK_E2E_UPDATE_BASELINES=1 task project:test:storyboard:e2e # regenerate drifted baselines + committed SVGs, then LOOK at them
377
+ TASK_E2E_UPDATE_BASELINES=1 task project:test:storyboard:svg
378
+ TASK_E2E_UPDATE_BASELINES=1 task project:test:storyboard:markdown
281
379
  task code # linters (MegaLinter)
282
380
  ```
283
381
 
284
382
  The e2e suite is the plugin's own dogfood: every scenario is a storyboard rendered by the plugin under test, committed under `tests/e2e/storyboards/`.
285
383
 
286
- The [installation storyboard](tests/e2e/storyboards/06-installation/storyboard-consumer.svg) packs the current source, installs the tarball into a fresh project, and runs the README configuration verbatim.
384
+ Open the [Markdown gallery](tests/e2e/storyboards/index.md) on the merge request
385
+ branch to review installation, Gherkin rules, compatibility and the Markdown consumer with relative screenshot links. Regenerate
386
+ these reviewed Markdown files with `TASK_E2E_UPDATE_BASELINES=1 task project:test:storyboard:markdown`.
387
+ The main suite explicitly selects SVG to retain its existing SVG regression coverage.
388
+ Use both recording commands above to preserve the reviewed format selection, then inspect the generated
389
+ boards. The SVG recording task excludes exactly those four Markdown journeys.
390
+
391
+ The [installation storyboard](tests/e2e/storyboards/06-installation/storyboard-consumer.md) packs the current source, installs the tarball into a fresh project, and runs the README configuration with explicit SVG selection. The Markdown consumer journey exercises the omitted-format default separately.
287
392
  It checks CodeceptJS 4.2.0, Playwright 1.63.0 and VisualHelper 1.3.5 in Chromium.
288
393
  It opens the generated `index.html` and SVG, repeats the run with strict baselines, then proves that a changed page fails on its exact sentence.
289
394
 
290
- The [consumer manifest](tests/e2e/consumer/package.json) pins those tools and overrides vulnerable transitive dependencies. Its lockfile makes the test repeatable. The separate [version matrix](tests/e2e/features/08-compatibility/matrix.feature) verifies the six combinations listed above. Complete installation and run logs are kept in `tests/e2e/_output/consumer-install.log` and `tests/e2e/_output/matrix/`.
395
+ The [consumer manifest](tests/e2e/consumer/package.json) pins those tools and overrides vulnerable transitive
396
+ dependencies. Its lockfile makes the test repeatable. The separate [version
397
+ matrix](tests/e2e/features/08-compatibility/matrix.feature) verifies the six combinations listed above.
398
+ Complete installation and run logs are kept in `tests/e2e/_output/consumer-install.log` and
399
+ `tests/e2e/_output/matrix/`.
291
400
 
292
401
  The clean-consumer test also copies the replay command from the generated gallery
293
402
  and executes it unchanged, then checks that every strict baseline hash is intact.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@digital-commons-official/codeceptjs-storyboard",
3
- "version": "1.0.2",
4
- "description": "Storyboard plugin for CodeceptJS: one Gherkin sentence = one card = one pixel baseline, and every scenario renders itself as a single SVG storyboard",
3
+ "version": "2.0.0",
4
+ "description": "Storyboard plugin for CodeceptJS: one Gherkin sentence = one card = one pixel baseline, with Markdown or SVG reports",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
7
7
  "exports": {
@@ -32,6 +32,7 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "@digital-commons-official/codeceptjs-visual-helper": "2.0.4",
35
+ "@onitofu/gherkin-lint": "5.0.0",
35
36
  "codeceptjs": "4.2.0",
36
37
  "playwright": "1.63.0",
37
38
  "standard": "^17.1.2",
@@ -55,7 +56,8 @@
55
56
  "bdd",
56
57
  "e2e-testing",
57
58
  "playwright",
58
- "svg"
59
+ "svg",
60
+ "markdown"
59
61
  ],
60
62
  "author": "Digital Commons",
61
63
  "license": "EUPL-1.2",
package/src/gallery.js CHANGED
@@ -1,5 +1,6 @@
1
1
  const fs = require('fs')
2
2
  const path = require('path')
3
+ const { text, codeBlock, relativeLink } = require('./markdown')
3
4
 
4
5
  function escape (value) {
5
6
  return String(value || '').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;')
@@ -17,7 +18,7 @@ ${entry.rerun ? ` <pre><code>${escape(entry.rerun)}</code></pre>` : ''}
17
18
 
18
19
  // Entries come from this run's test events, never from a directory listing:
19
20
  // a filtered rerun must not make yesterday's pictures look freshly checked.
20
- module.exports = function writeGallery (directory, entries) {
21
+ module.exports = function writeGallery (directory, entries, format = 'svg') {
21
22
  const groups = new Map()
22
23
  for (const entry of entries) {
23
24
  const group = path.dirname(entry.baseDir)
@@ -26,6 +27,25 @@ module.exports = function writeGallery (directory, entries) {
26
27
  }
27
28
  const hasFailure = entries => entries.some(entry => !entry.passed)
28
29
  const ordered = [...groups].sort(([a, aa], [b, bb]) => Number(hasFailure(bb)) - Number(hasFailure(aa)) || a.localeCompare(b))
30
+ if (format === 'markdown') {
31
+ const outFile = path.join(directory, 'index.md')
32
+ const sections = ordered.flatMap(([group, stories]) => [
33
+ `## ${text(group === '.' ? 'Scenarios' : group)}`,
34
+ ...[...stories].sort((a, b) => Number(a.passed) - Number(b.passed) || a.scenario.localeCompare(b.scenario)).flatMap(entry => [
35
+ `### [${text(entry.scenario).replace(/\r?\n/g, ' ')}](${relativeLink(outFile, path.join(directory, entry.baseDir + '.md'))})`,
36
+ `**${entry.passed ? 'Passed' : 'Failed'}**`,
37
+ ...(entry.sentence ? [text(entry.sentence)] : []),
38
+ ...(entry.rerun ? [codeBlock(entry.rerun)] : [])
39
+ ])
40
+ ])
41
+ fs.mkdirSync(directory, { recursive: true })
42
+ fs.writeFileSync(outFile, [
43
+ '# Storyboards',
44
+ 'Open a scenario to review its pictures. Copy its command to run it again.',
45
+ ...(sections.length ? sections : ['No storyboards in this run.'])
46
+ ].join('\n\n') + '\n')
47
+ return
48
+ }
29
49
  const content = ordered.map(([group, stories]) => {
30
50
  const rows = [...stories].sort((a, b) => Number(a.passed) - Number(b.passed) || a.scenario.localeCompare(b.scenario)).map(entryHtml).join('\n')
31
51
  return `<section>\n<h2>${escape(group === '.' ? 'Scenarios' : group)}</h2>\n<ul>${rows}</ul>\n</section>`
package/src/index.d.ts CHANGED
@@ -91,14 +91,32 @@ export interface Theme {
91
91
  }
92
92
 
93
93
  export interface StoryboardConfig {
94
+ /** Generate exactly one format. Defaults to Markdown; SVG must be selected explicitly. */
95
+ format?: 'markdown' | 'svg'
94
96
  /** Replay command template; {tag} is the scenario's last tag. Defaults to npx codeceptjs run --steps --grep "{tag}". */
95
97
  replayCommand?: string
96
- /** Theme object, CSS file relative to codecept.conf.js, or HTTP(S) CSS URL. */
98
+ /** SVG-only theme object, CSS file relative to codecept.conf.js, or HTTP(S) CSS URL. Markdown does not load themes. */
97
99
  theme?: Theme | string
100
+ /** Markdown presentation. GitLab still controls page styling and native alerts. */
101
+ markdown?: MarkdownPresentation
98
102
  [option: string]: unknown
99
103
  }
100
104
 
105
+ export interface MarkdownPresentation {
106
+ /** Local banner colours, in 3/6-digit hex. Text is selected for contrast when omitted. */
107
+ colors?: { banner?: string, bannerText?: string, accent?: string }
108
+ /** Cards per row; defaults to 2. Use 1 for narrow readers. */
109
+ columns?: 1 | 2
110
+ /** Show chapter/result/replay navigation; defaults to true. */
111
+ tableOfContents?: boolean
112
+ /** Commands and replay/source details; defaults to collapsed. */
113
+ technicalDetails?: 'collapsed' | 'expanded'
114
+ }
115
+
101
116
  export interface RenderOptions {
117
+ markdown?: MarkdownPresentation
118
+ /** Explicit test outcome; omitted means unknown. Failure evidence takes precedence. */
119
+ outcome?: 'passed' | 'failed'
102
120
  /** Inline overrides for standalone rendering. */
103
121
  theme?: Theme
104
122
  /** Substitute every frame with the same-named PNG inside this directory (the reviewed baselines). */
@@ -141,7 +159,7 @@ declare namespace storyboardPlugin {
141
159
  function assertOrUpdateBaseline (I: StoryboardActor, baselineName: string): Promise<void>
142
160
  /** Attach the frame to the open card and assert it against its own baseline at tolerance 0. */
143
161
  function addStoryboardFrame (I: StoryboardActor, png: string): Promise<void>
144
- /** Write the storyboard SVG of the cards captured so far; returns outFile. */
162
+ /** Write the captured cards as Markdown (.md) or SVG (.svg), selected by extension; returns outFile. */
145
163
  function render (outFile: string, options?: RenderOptions): string
146
164
  /** Re-export of codeceptjs/effects tryTo. */
147
165
  function tryTo (fn: () => unknown): Promise<boolean>
package/src/index.js CHANGED
@@ -57,6 +57,7 @@ const { PNG } = require('pngjs')
57
57
  const { tryTo } = require('codeceptjs/effects')
58
58
  const { PROPERTIES, normalizeTheme, loadTheme } = require('./theme')
59
59
  const { readScenario } = require('./gherkin')
60
+ const { normalizeMarkdown } = require('./markdown-presentation')
60
61
 
61
62
  let board = null
62
63
 
@@ -258,7 +259,7 @@ async function addStoryboardFrame (I, png) {
258
259
  err.message +=
259
260
  `\n storyboard frame : ${name}.png` +
260
261
  `\n pixel diff : screenshots/diff/${path.dirname(name)}/Diff_${path.basename(name)}.png` +
261
- `\n failure storyboard : _output/${board && board.baseDir ? board.baseDir : '<scenario>'}.svg` +
262
+ `\n failure storyboard : _output/${board && board.baseDir ? board.baseDir : '<scenario>'}.${board && board.format === 'markdown' ? 'md' : 'svg'}` +
262
263
  (board && board.rerun
263
264
  ? `\n deliberate change? regenerate locally, then inspect: TASK_E2E_UPDATE_BASELINES=1 ${board.rerun}`
264
265
  : '')
@@ -353,6 +354,9 @@ function render (outFile, options = {}) {
353
354
  if (!board || !board.panels.length) {
354
355
  throw new Error('storyboard.render() called with no panels')
355
356
  }
357
+ const extension = path.extname(outFile)
358
+ if (extension === '.md') return require('./markdown').renderMarkdown(board, outFile, options)
359
+ if (extension !== '.svg') throw new Error('storyboard.render() requires a .md or .svg file extension')
356
360
  const custom = normalizeTheme(options.theme || board.theme || {})
357
361
  const t = { ...THEME }
358
362
  const declarations = Object.entries(custom).map(([key, value]) => {
@@ -758,12 +762,12 @@ function buildFailure (board) {
758
762
  // One unmissable block in the runner output: WHERE to look. The path is
759
763
  // repo-relative — valid on the host once the artifact sync (end of the run)
760
764
  // has copied _output back.
761
- function logVisualRegression (frame, outputSvg) {
765
+ function logVisualRegression (frame, outputFile) {
762
766
  console.error(
763
767
  '\n════════════════════════════════════════════════════════════════\n' +
764
768
  `✖ VISUAL REGRESSION — step ${frame.step}: ${sentenceOf(frame, frame.sentence)}\n` +
765
769
  ' The failure storyboard sums it all up (expected / diff / actual):\n' +
766
- ` 🎬 open in a browser: ${path.relative(process.cwd(), outputSvg)}\n` +
770
+ ` 🎬 ${outputFile.endsWith('.md') ? 'open with a Markdown viewer' : 'open in a browser'}: ${path.relative(process.cwd(), outputFile)}\n` +
767
771
  '════════════════════════════════════════════════════════════════\n'
768
772
  )
769
773
  }
@@ -779,7 +783,16 @@ function logVisualRegression (frame, outputSvg) {
779
783
  // codeceptjs 3.7.8 sets test.title / test.tags / test.file / test.parent.title
780
784
  // (feature name) in lib/mocha/gherkin.js; titles carry the tags appended.
781
785
  // ---------------------------------------------------------------------------
786
+ function resolveFormat (value) {
787
+ if (value === undefined) return 'markdown'
788
+ if (value === 'markdown' || value === 'svg') return value
789
+ throw new Error('storyboard format must be "markdown" or "svg" (one format per run)')
790
+ }
791
+
782
792
  module.exports = function storyboardPlugin (config = {}) {
793
+ const format = resolveFormat(config.format)
794
+ const markdown = format === 'markdown' ? normalizeMarkdown(config.markdown) : undefined
795
+ const extension = format === 'markdown' ? 'md' : 'svg'
783
796
  const { event, recorder, container } = require('codeceptjs')
784
797
  const replayCommand = config.replayCommand ?? 'npx codeceptjs run --steps --grep "{tag}"'
785
798
  const writeGallery = require('./gallery')
@@ -822,8 +835,10 @@ module.exports = function storyboardPlugin (config = {}) {
822
835
  baseDir: base,
823
836
  rerun: tag ? replayCommand.replaceAll('{tag}', tag) : ''
824
837
  })
838
+ board.format = format
839
+ board.markdown = markdown
825
840
  if (board.exampleLine) board.baseDir += `-example-${board.exampleLine}`
826
- if (config.theme) {
841
+ if (format === 'svg' && config.theme) {
827
842
  const current = board
828
843
  recorder.add('load storyboard theme', async () => {
829
844
  themePromise = themePromise || loadTheme(config.theme, e2eDir())
@@ -851,7 +866,8 @@ module.exports = function storyboardPlugin (config = {}) {
851
866
  // diff-less failure (e.g. "Image dimensions do not match") the band's
852
867
  // middle slot reads "(not generated)".
853
868
  const failure = passed ? null : buildFailure(board)
854
- const outputSvg = render(path.join(global.codecept_dir, '_output', `${board.baseDir}.svg`), { failure })
869
+ const outcome = passed ? 'passed' : 'failed'
870
+ const outputFile = render(path.join(global.codecept_dir, '_output', `${board.baseDir}.${extension}`), { failure, outcome })
855
871
  entries.set(board.baseDir, {
856
872
  baseDir: board.baseDir,
857
873
  scenario: board.scenario,
@@ -859,15 +875,16 @@ module.exports = function storyboardPlugin (config = {}) {
859
875
  passed,
860
876
  sentence: failure && failure.frame ? failure.frame.sentence : ''
861
877
  })
862
- if (failure && failure.frame) logVisualRegression(failure.frame, outputSvg)
863
- if (passed && process.env.TASK_E2E_UPDATE_BASELINES === '1') {
864
- render(path.join(global.codecept_dir, 'storyboards', `${board.baseDir}.svg`), {
878
+ if (failure && failure.frame) logVisualRegression(failure.frame, outputFile)
879
+ if (passed && process.env.TASK_E2E_UPDATE_BASELINES === '1' && !process.env.CI) {
880
+ render(path.join(global.codecept_dir, 'storyboards', `${board.baseDir}.${extension}`), {
881
+ outcome,
865
882
  imageDir: path.join(global.codecept_dir, 'screenshots', 'base', board.baseDir)
866
883
  })
867
884
  }
868
885
  } catch (err) {
869
886
  // Rendering must never mask the test outcome.
870
- console.error(`storyboard: SVG rendering failed: ${err.message}`)
887
+ console.error(`storyboard: ${format === 'svg' ? 'SVG' : 'Markdown'} rendering failed: ${err.message}`)
871
888
  }
872
889
  }
873
890
  event.dispatcher.on(event.test.passed, () => finish(true))
@@ -876,9 +893,9 @@ module.exports = function storyboardPlugin (config = {}) {
876
893
  if (!global.codecept_dir) return
877
894
  try {
878
895
  const stories = [...entries.values()]
879
- writeGallery(path.join(global.codecept_dir, '_output'), stories)
896
+ writeGallery(path.join(global.codecept_dir, '_output'), stories, format)
880
897
  if (process.env.TASK_E2E_UPDATE_BASELINES === '1' && !process.env.CI) {
881
- writeGallery(path.join(global.codecept_dir, 'storyboards'), stories.filter(entry => entry.passed))
898
+ writeGallery(path.join(global.codecept_dir, 'storyboards'), stories.filter(entry => entry.passed), format)
882
899
  }
883
900
  } catch (err) {
884
901
  console.error(`storyboard: gallery rendering failed: ${err.message}`)
@@ -0,0 +1,71 @@
1
+ const fs = require('fs')
2
+ const path = require('path')
3
+ const { createHash } = require('crypto')
4
+
5
+ const DEFAULT_COLORS = { banner: '#155e50', bannerText: '#ffffff', accent: '#559b84' }
6
+
7
+ function object (value, keys, label) {
8
+ if (!value || typeof value !== 'object' || Array.isArray(value) || Object.keys(value).some(key => !keys.includes(key))) {
9
+ throw new Error(`storyboard markdown ${label} must be an object with supported keys: ${keys.join(', ')}`)
10
+ }
11
+ }
12
+
13
+ function luminance (color) {
14
+ const hex = color.slice(1)
15
+ const expanded = hex.length === 3 ? [...hex].map(character => character + character).join('') : hex
16
+ return [0, 2, 4].map(start => parseInt(expanded.slice(start, start + 2), 16) / 255)
17
+ .map(value => value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4)
18
+ .reduce((total, value, index) => total + value * [0.2126, 0.7152, 0.0722][index], 0)
19
+ }
20
+
21
+ function contrast (background, foreground) {
22
+ const values = [luminance(background), luminance(foreground)].sort((a, b) => b - a)
23
+ return (values[0] + 0.05) / (values[1] + 0.05)
24
+ }
25
+
26
+ function normalizeMarkdown (value = {}) {
27
+ object(value, ['colors', 'columns', 'tableOfContents', 'technicalDetails'], 'options')
28
+ const supplied = value.colors === undefined ? {} : value.colors
29
+ object(supplied, Object.keys(DEFAULT_COLORS), 'colors')
30
+ const colors = { ...DEFAULT_COLORS, ...supplied }
31
+ for (const [key, color] of Object.entries(colors)) {
32
+ if (typeof color !== 'string' || !/^#(?:[\da-f]{3}|[\da-f]{6})$/i.test(color)) {
33
+ throw new Error(`storyboard markdown colors.${key} must be a 3- or 6-digit hex colour`)
34
+ }
35
+ }
36
+ if (supplied.banner !== undefined && supplied.bannerText === undefined) {
37
+ colors.bannerText = contrast(colors.banner, '#ffffff') >= contrast(colors.banner, '#111111') ? '#ffffff' : '#111111'
38
+ if (contrast(colors.banner, colors.bannerText) < 4.5) colors.bannerText = '#000000'
39
+ }
40
+ if (contrast(colors.banner, colors.bannerText) < 4.5) throw new Error('storyboard markdown banner text contrast must be at least 4.5:1')
41
+ const options = { columns: 2, tableOfContents: true, technicalDetails: 'collapsed', ...value, colors }
42
+ if (![1, 2].includes(options.columns)) throw new Error('storyboard markdown columns must be 1 or 2')
43
+ if (typeof options.tableOfContents !== 'boolean') throw new Error('storyboard markdown tableOfContents must be a boolean')
44
+ if (!['collapsed', 'expanded'].includes(options.technicalDetails)) throw new Error('storyboard markdown technicalDetails must be "collapsed" or "expanded"')
45
+ return options
46
+ }
47
+
48
+ function xml (value) {
49
+ return String(value).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&apos;')
50
+ }
51
+
52
+ // Banners carry decoration only: the full chapter title also remains native
53
+ // Markdown, selectable and readable when images are unavailable or small.
54
+ function writeBanner (outFile, title, number, colors) {
55
+ const characters = Array.from(String(title).replace(/\s+/g, ' ').trim())
56
+ const label = characters.length > 38 ? characters.slice(0, 37).join('') + '…' : characters.join('')
57
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="1120" height="104" viewBox="0 0 1120 104" role="img">
58
+ <title>${xml(title)}</title>
59
+ <rect width="1120" height="104" rx="8" fill="${colors.banner}"/>
60
+ <path d="M940 0h70l104 104h-70z M1060 0h30l30 30v74z" fill="${colors.accent}"/>
61
+ <text x="28" y="32" font-family="Arial, sans-serif" font-size="15" fill="${colors.bannerText}">${number ? 'Chapter ' + number : 'Journey'}</text>
62
+ <text x="28" y="73" font-family="Arial, sans-serif" font-size="26" font-weight="700" fill="${colors.bannerText}">${xml(label)}</text>
63
+ </svg>\n`
64
+ const digest = createHash('sha256').update(svg).digest('hex').slice(0, 20)
65
+ const file = path.join(path.dirname(outFile), '_storyboard-assets', `banner-${digest}.svg`)
66
+ fs.mkdirSync(path.dirname(file), { recursive: true })
67
+ fs.writeFileSync(file, svg)
68
+ return file
69
+ }
70
+
71
+ module.exports = { normalizeMarkdown, writeBanner }
@@ -0,0 +1,149 @@
1
+ const fs = require('fs')
2
+ const path = require('path')
3
+ const { normalizeMarkdown, writeBanner } = require('./markdown-presentation')
4
+
5
+ // Annotations are plain text, not another source of Markdown or HTML.
6
+ function text (value) {
7
+ return String(value ?? '')
8
+ .replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')
9
+ .replace(/[\\`*_{}[\]|~=#]/g, '\\$&')
10
+ .replace(/^(\s*)([#+-])/gm, '$1\\$2')
11
+ .replace(/^(\s*\d+)([.)])/gm, '$1\\$2')
12
+ }
13
+
14
+ function codeBlock (value, language = '') {
15
+ const content = String(value)
16
+ const runs = content.match(/`+/g) || []
17
+ const fence = '`'.repeat(Math.max(3, ...runs.map(run => run.length + 1)))
18
+ return `${fence}${language}\n${content}\n${fence}`
19
+ }
20
+
21
+ function relativeLink (outFile, file) {
22
+ return path.relative(path.dirname(outFile), file).split(path.sep)
23
+ .map(segment => encodeURIComponent(segment).replace(/[!'()*]/g, character => `%${character.charCodeAt(0).toString(16).toUpperCase()}`))
24
+ .join('/')
25
+ }
26
+
27
+ function sentence (line, fallback = '') {
28
+ if (!line) return fallback
29
+ const separator = line.keywordSeparator === undefined ? ' ' : line.keywordSeparator
30
+ return (line.keyword ? line.keyword + separator : '') + (line.text ?? fallback)
31
+ }
32
+
33
+ function caption (value) {
34
+ return text(value).replace(/\r?\n/g, ' ')
35
+ }
36
+
37
+ function image (outFile, file, alt) {
38
+ if (!file || !fs.existsSync(file)) return '(image not available)'
39
+ const url = relativeLink(outFile, file)
40
+ return `[![${caption(alt)}](${url})](${url})`
41
+ }
42
+
43
+ function cardsOf (board, imageDir) {
44
+ return board.panels.flatMap((panel, index) => panel.images.map((frame, imageIndex) => ({
45
+ number: index + 1,
46
+ title: sentence(panel.line, panel.title),
47
+ chapter: imageIndex === 0 && panel.line ? panel.line.chapter : null,
48
+ file: imageDir ? path.join(imageDir, path.basename(frame.file)) : frame.file,
49
+ note: frame.note !== undefined ? frame.note : (imageIndex === 0 ? panel.note || (panel.line && panel.line.note) || '' : ''),
50
+ copy: frame.copy !== undefined ? frame.copy : (imageIndex === 0 ? panel.copy || (panel.line && panel.line.copy) || '' : '')
51
+ })))
52
+ }
53
+
54
+ function details (title, content, presentation) {
55
+ const open = presentation.technicalDetails === 'expanded' ? ' open' : ''
56
+ return `<details${open}>\n<summary>${title}</summary>\n\n${content}\n\n</details>`
57
+ }
58
+
59
+ function annotations (card, presentation) {
60
+ if (!card.note && !card.copy) return []
61
+ return [
62
+ ...(card.note ? [text(card.note)] : []),
63
+ ...(card.copy ? [details('Command', codeBlock(card.copy, 'shell'), presentation)] : [])
64
+ ]
65
+ }
66
+
67
+ function pair (outFile, cards, presentation) {
68
+ const columns = presentation.columns === 2 && cards.length === 1 ? [...cards, null] : cards
69
+ const width = 100 / presentation.columns
70
+ const headings = columns.map(card => `<th width="${width}%">\n\n${card ? `**${card.number}. ${caption(card.title)}**` : ''}\n\n</th>`)
71
+ const bodies = columns.map(card => `<td width="${width}%" valign="top">\n\n${card ? [image(outFile, card.file, card.title), ...annotations(card, presentation)].join('\n\n') : ''}\n\n</td>`)
72
+ return `<table width="100%">\n<tr>\n${headings.join('\n')}\n</tr>\n<tr>\n${bodies.join('\n')}\n</tr>\n</table>`
73
+ }
74
+
75
+ function comparison (outFile, card, frame, presentation) {
76
+ const pictures = [
77
+ image(outFile, frame.baseline, 'Expected'),
78
+ frame.diff ? image(outFile, frame.diff, 'Diff') : '(not generated)',
79
+ image(outFile, frame.actual, 'Actual')
80
+ ]
81
+ const paths = frame.paths || {}
82
+ return [
83
+ `## Visual regression — step ${frame.step}: ${caption(card.title)}`,
84
+ `| Expected | Diff | Actual |\n| --- | --- | --- |\n| ${pictures.join(' | ')} |`,
85
+ ...['expected', 'diff', 'actual'].flatMap(label => [
86
+ `**${label[0].toUpperCase() + label.slice(1)} path**`,
87
+ codeBlock(paths[label] || '(not available)')
88
+ ]),
89
+ ...annotations(card, presentation)
90
+ ]
91
+ }
92
+
93
+ function renderMarkdown (board, outFile, options = {}) {
94
+ const presentation = normalizeMarkdown(options.markdown === undefined ? board.markdown : options.markdown)
95
+ const cards = cardsOf(board, options.imageDir)
96
+ const failure = options.failure
97
+ const verdict = failure || options.outcome === 'failed' ? 'FAILED' : options.outcome === 'passed' ? 'PASSED' : 'Outcome not recorded'
98
+ const chapters = cards.filter(card => card.chapter)
99
+ const summary = `${board.lines.length || board.panels.length} steps · ${cards.length} frames`
100
+ const chunks = [
101
+ `# ${caption(board.feature || 'Storyboard')}`,
102
+ `**${caption(board.scenarioKeyword || 'Scenario')}:** ${caption(board.scenario)}`,
103
+ '<a name="storyboard-result"></a>',
104
+ `> [!${verdict === 'FAILED' ? 'caution' : verdict === 'PASSED' ? 'tip' : 'note'}] ${verdict}\n> ${summary}`
105
+ ]
106
+ if (presentation.tableOfContents) {
107
+ chunks.push('**On this page**', [
108
+ '[Result](#storyboard-result)',
109
+ ...chapters.map((card, index) => `[${caption(card.chapter)}](#storyboard-chapter-${index + 1})`),
110
+ '[Replay and source](#storyboard-replay)'
111
+ ].join(' · '))
112
+ }
113
+ if (!chapters.length) chunks.push(`![Journey banner](${relativeLink(outFile, writeBanner(outFile, board.scenario || board.feature || 'Storyboard', 0, presentation.colors))})`)
114
+ let pending = []
115
+ let chapterNumber = 0
116
+ const flush = () => {
117
+ if (pending.length) chunks.push(pair(outFile, pending, presentation))
118
+ pending = []
119
+ }
120
+ for (const card of cards) {
121
+ if (card.chapter) {
122
+ flush()
123
+ chapterNumber++
124
+ const banner = writeBanner(outFile, card.chapter, chapterNumber, presentation.colors)
125
+ chunks.push(`<a name="storyboard-chapter-${chapterNumber}"></a>`, `![Chapter ${chapterNumber} banner](${relativeLink(outFile, banner)})`, `## ${caption(card.chapter).trim()}`)
126
+ }
127
+ if (failure && failure.frame && path.basename(card.file) === failure.frame.name) {
128
+ flush()
129
+ chunks.push(...comparison(outFile, card, failure.frame, presentation))
130
+ } else {
131
+ pending.push(card)
132
+ if (pending.length === presentation.columns) flush()
133
+ }
134
+ }
135
+ flush()
136
+ if (failure && failure.notReached && failure.notReached.length) {
137
+ chunks.push('## Not reached', failure.notReached.map(line => `- ${caption(sentence(line))}`).join('\n'))
138
+ }
139
+ chunks.push('<a name="storyboard-replay"></a>', details('Replay this scenario · source and checks', [
140
+ ...(board.rerun ? [codeBlock(board.rerun, 'shell')] : []),
141
+ ...(board.file ? ['**Source**', codeBlock(board.file, 'text')] : []),
142
+ 'Every frame is its own pixel baseline (tolerance: 0).'
143
+ ].join('\n\n'), presentation))
144
+ fs.mkdirSync(path.dirname(outFile), { recursive: true })
145
+ fs.writeFileSync(outFile, chunks.join('\n\n') + '\n')
146
+ return outFile
147
+ }
148
+
149
+ module.exports = { renderMarkdown, text, codeBlock, relativeLink }