@digital-commons-official/codeceptjs-storyboard 3.2.3 → 3.3.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 +24 -1
- package/package.json +1 -1
- package/src/gallery.js +1 -0
- package/src/index.d.ts +5 -0
- package/src/index.js +75 -1
- package/src/markdown.js +97 -28
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ Their signatures are defined in [src/index.d.ts](src/index.d.ts).
|
|
|
64
64
|
| `parseScenarioLines`, `render` | Read the original Gherkin sentences and render Markdown or SVG. |
|
|
65
65
|
| `tryTo` | Re-export the CodeceptJS effect for an optional action. |
|
|
66
66
|
|
|
67
|
-
The supported plugin options are `format`, `theme`, `markdown` and `
|
|
67
|
+
The supported plugin options are `format`, `theme`, `markdown`, `replayCommand` and `groupBy`; CodeceptJS owns
|
|
68
68
|
`require` and `enabled`. From 1.0.0, compatible releases preserve this public
|
|
69
69
|
API and the documented baseline recording behaviour. Removing a public
|
|
70
70
|
function, changing its required arguments or raising a supported minimum
|
|
@@ -201,6 +201,29 @@ theme behaviour and ignores Markdown presentation settings.
|
|
|
201
201
|
Standalone callers can use `render('report.md', { markdown: { columns: 1 }, outcome: 'passed' })`.
|
|
202
202
|
Only provide `outcome` when it is known; failure evidence always takes precedence over a passed value.
|
|
203
203
|
|
|
204
|
+
### One storyboard per feature
|
|
205
|
+
|
|
206
|
+
By default each scenario gets its own page. Set `groupBy: 'feature'` to write one page per
|
|
207
|
+
`.feature` file instead. Each scenario becomes a chapter of the page, in the order it ran, and its
|
|
208
|
+
own chapters sit one level below:
|
|
209
|
+
|
|
210
|
+
```javascript
|
|
211
|
+
storyboard: {
|
|
212
|
+
require: '@digital-commons-official/codeceptjs-storyboard',
|
|
213
|
+
enabled: true,
|
|
214
|
+
groupBy: 'feature'
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
`features/release/helm-publish.feature` then gives `storyboards/release/helm-publish.md`. The index
|
|
219
|
+
shows one entry per feature, the list of its scenarios, and one command built from the last tag of
|
|
220
|
+
the `Feature` line, so give each feature its own tag. The reviewed screenshots keep their
|
|
221
|
+
per-scenario directories, so switching needs no new baseline.
|
|
222
|
+
|
|
223
|
+
A run that records only some scenarios of a feature keeps its reviewed page and says so: record the
|
|
224
|
+
whole feature to rewrite it. `groupBy: 'feature'` needs the Markdown format and is refused with
|
|
225
|
+
`format: 'svg'`.
|
|
226
|
+
|
|
204
227
|
### Replay commands
|
|
205
228
|
|
|
206
229
|
The gallery and storyboard default to `npx codeceptjs run --steps --grep "{tag}"`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digital-commons-official/codeceptjs-storyboard",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
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
|
"bin": {
|
package/src/gallery.js
CHANGED
|
@@ -34,6 +34,7 @@ module.exports = function writeGallery (directory, entries, format = 'svg') {
|
|
|
34
34
|
...[...stories].sort((a, b) => Number(a.passed) - Number(b.passed) || a.scenario.localeCompare(b.scenario)).flatMap(entry => [
|
|
35
35
|
`### [${text(entry.scenario).replace(/\r?\n/g, ' ')}](${relativeLink(outFile, path.join(directory, entry.baseDir + '.md'))})`,
|
|
36
36
|
`**${entry.passed ? 'Passed' : 'Failed'}**`,
|
|
37
|
+
...(entry.scenarios ? [entry.scenarios.map(scenario => `- ${text(scenario).replace(/\r?\n/g, ' ')}`).join('\n')] : []),
|
|
37
38
|
...(entry.sentence ? [text(entry.sentence)] : []),
|
|
38
39
|
...(entry.rerun ? [codeBlock(entry.rerun)] : [])
|
|
39
40
|
])
|
package/src/index.d.ts
CHANGED
|
@@ -99,6 +99,11 @@ export interface StoryboardConfig {
|
|
|
99
99
|
theme?: Theme | string
|
|
100
100
|
/** Markdown presentation. GitLab still controls page styling and native alerts. */
|
|
101
101
|
markdown?: MarkdownPresentation
|
|
102
|
+
/**
|
|
103
|
+
* One storyboard per scenario (default) or one per feature file, each scenario a chapter of it.
|
|
104
|
+
* 'feature' needs the Markdown format and replays the feature with its last Feature tag.
|
|
105
|
+
*/
|
|
106
|
+
groupBy?: 'scenario' | 'feature'
|
|
102
107
|
[option: string]: unknown
|
|
103
108
|
}
|
|
104
109
|
|
package/src/index.js
CHANGED
|
@@ -289,7 +289,7 @@ async function addStoryboardFrame (I, png) {
|
|
|
289
289
|
err.message +=
|
|
290
290
|
`\n storyboard frame : ${name}${extension}` +
|
|
291
291
|
`\n pixel diff : screenshots/diff/${path.dirname(name)}/Diff_${path.basename(name)}${extension}` +
|
|
292
|
-
`\n failure storyboard : _output/${board && board.baseDir ? board.baseDir : '<scenario>'}.${board && board.format === 'markdown' ? 'md' : 'svg'}` +
|
|
292
|
+
`\n failure storyboard : _output/${board && (board.report || board.baseDir) ? board.report || board.baseDir : '<scenario>'}.${board && board.format === 'markdown' ? 'md' : 'svg'}` +
|
|
293
293
|
(board && board.rerun
|
|
294
294
|
? `\n deliberate change? regenerate locally, then inspect: TASK_E2E_UPDATE_BASELINES=1 ${board.rerun}`
|
|
295
295
|
: '')
|
|
@@ -844,20 +844,32 @@ function resolveFormat (value) {
|
|
|
844
844
|
throw new Error('storyboard format must be "markdown" or "svg" (one format per run)')
|
|
845
845
|
}
|
|
846
846
|
|
|
847
|
+
function resolveGroupBy (value, format) {
|
|
848
|
+
if (value === undefined || value === 'scenario') return 'scenario'
|
|
849
|
+
if (value !== 'feature') throw new Error('storyboard groupBy must be "scenario" or "feature"')
|
|
850
|
+
if (format !== 'markdown') throw new Error('storyboard groupBy "feature" needs format "markdown": one page per feature is a Markdown page')
|
|
851
|
+
return value
|
|
852
|
+
}
|
|
853
|
+
|
|
847
854
|
module.exports = function storyboardPlugin (config = {}) {
|
|
848
855
|
const format = resolveFormat(config.format)
|
|
856
|
+
const groupBy = resolveGroupBy(config.groupBy, format)
|
|
849
857
|
const markdown = format === 'markdown' ? normalizeMarkdown(config.markdown) : undefined
|
|
850
858
|
const extension = format === 'markdown' ? 'md' : 'svg'
|
|
851
859
|
const { event, recorder, container } = require('codeceptjs')
|
|
852
860
|
const replayCommand = config.replayCommand ?? 'npx codeceptjs run --steps --grep "{tag}"'
|
|
853
861
|
const writeGallery = require('./gallery')
|
|
854
862
|
const entries = new Map()
|
|
863
|
+
// groupBy 'feature': one group per feature file, filled as its scenarios
|
|
864
|
+
// end and rendered once the run is over.
|
|
865
|
+
const features = new Map()
|
|
855
866
|
let themePromise
|
|
856
867
|
event.dispatcher.prependListener(event.all.before, () => {
|
|
857
868
|
require('./rules')(container.mocha())
|
|
858
869
|
})
|
|
859
870
|
event.dispatcher.on(event.all.before, () => {
|
|
860
871
|
entries.clear()
|
|
872
|
+
features.clear()
|
|
861
873
|
themePromise = null
|
|
862
874
|
})
|
|
863
875
|
event.dispatcher.on(event.test.before, (test) => {
|
|
@@ -865,6 +877,7 @@ module.exports = function storyboardPlugin (config = {}) {
|
|
|
865
877
|
const tag = tags.length ? tags[tags.length - 1] : ''
|
|
866
878
|
let file = ''
|
|
867
879
|
let base = ''
|
|
880
|
+
let featureKey = ''
|
|
868
881
|
if (test.file && global.codecept_dir) {
|
|
869
882
|
// Display path relative to the process cwd (the repo root in the
|
|
870
883
|
// container), correct wherever the suite lives in a given project.
|
|
@@ -879,6 +892,7 @@ module.exports = function storyboardPlugin (config = {}) {
|
|
|
879
892
|
? tag.replace(/^@/, '')
|
|
880
893
|
: stripTags(test.title).toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '')
|
|
881
894
|
base = path.join(path.dirname(fromFeatures), scenarioKey)
|
|
895
|
+
featureKey = path.join(path.dirname(fromFeatures), path.basename(fromFeatures, path.extname(fromFeatures)))
|
|
882
896
|
}
|
|
883
897
|
}
|
|
884
898
|
begin({
|
|
@@ -893,6 +907,26 @@ module.exports = function storyboardPlugin (config = {}) {
|
|
|
893
907
|
board.format = format
|
|
894
908
|
board.markdown = markdown
|
|
895
909
|
if (board.exampleLine) board.baseDir += `-example-${board.exampleLine}`
|
|
910
|
+
if (groupBy === 'feature' && featureKey) {
|
|
911
|
+
board.report = featureKey
|
|
912
|
+
if (!features.has(featureKey)) {
|
|
913
|
+
// The feature's own tag is the last tag of the Feature line; the
|
|
914
|
+
// scenario tags come after it in test.tags.
|
|
915
|
+
const featureTags = (test.parent && test.parent.tags) || []
|
|
916
|
+
const featureTag = featureTags.length ? featureTags[featureTags.length - 1] : ''
|
|
917
|
+
const siblings = (test.parent && test.parent.tests) || [test]
|
|
918
|
+
features.set(featureKey, {
|
|
919
|
+
key: featureKey,
|
|
920
|
+
feature: board.feature,
|
|
921
|
+
rerun: featureTag ? replayCommand.replaceAll('{tag}', featureTag) : '',
|
|
922
|
+
scenarios: [...new Set(siblings.map(other => stripTags(other.title)))],
|
|
923
|
+
expected: siblings.length,
|
|
924
|
+
ran: 0,
|
|
925
|
+
items: []
|
|
926
|
+
})
|
|
927
|
+
}
|
|
928
|
+
features.get(featureKey).ran++
|
|
929
|
+
}
|
|
896
930
|
if (format === 'svg' && config.theme) {
|
|
897
931
|
const current = board
|
|
898
932
|
recorder.add('load storyboard theme', async () => {
|
|
@@ -922,6 +956,11 @@ module.exports = function storyboardPlugin (config = {}) {
|
|
|
922
956
|
// middle slot reads "(not generated)".
|
|
923
957
|
const failure = passed ? null : buildFailure(board)
|
|
924
958
|
const outcome = passed ? 'passed' : 'failed'
|
|
959
|
+
if (board.report) {
|
|
960
|
+
features.get(board.report).items.push({ board, failure, outcome, passed })
|
|
961
|
+
if (failure && failure.frame) logVisualRegression(failure.frame, path.join(global.codecept_dir, '_output', `${board.report}.${extension}`))
|
|
962
|
+
return
|
|
963
|
+
}
|
|
925
964
|
const outputFile = render(path.join(global.codecept_dir, '_output', `${board.baseDir}.${extension}`), { failure, outcome })
|
|
926
965
|
entries.set(board.baseDir, {
|
|
927
966
|
baseDir: board.baseDir,
|
|
@@ -942,11 +981,46 @@ module.exports = function storyboardPlugin (config = {}) {
|
|
|
942
981
|
console.error(`storyboard: ${format === 'svg' ? 'SVG' : 'Markdown'} rendering failed: ${err.message}`)
|
|
943
982
|
}
|
|
944
983
|
}
|
|
984
|
+
// A filtered run never rewrites the reviewed page of a feature: the page
|
|
985
|
+
// would lose the scenarios that did not run.
|
|
986
|
+
const renderFeatures = () => {
|
|
987
|
+
for (const group of features.values()) {
|
|
988
|
+
if (!group.items.length) continue
|
|
989
|
+
const passed = group.items.every(item => item.passed)
|
|
990
|
+
const failed = group.items.find(item => item.failure && item.failure.frame)
|
|
991
|
+
const markdown = require('./markdown')
|
|
992
|
+
try {
|
|
993
|
+
markdown.renderFeatureMarkdown(group.items, path.join(global.codecept_dir, '_output', `${group.key}.${extension}`), { rerun: group.rerun })
|
|
994
|
+
entries.set(group.key, {
|
|
995
|
+
baseDir: group.key,
|
|
996
|
+
scenario: group.feature,
|
|
997
|
+
scenarios: group.scenarios,
|
|
998
|
+
rerun: group.rerun,
|
|
999
|
+
passed,
|
|
1000
|
+
sentence: failed ? failed.failure.frame.sentence : ''
|
|
1001
|
+
})
|
|
1002
|
+
if (!passed || process.env.TASK_E2E_UPDATE_BASELINES !== '1' || process.env.CI) continue
|
|
1003
|
+
if (group.ran < group.expected) {
|
|
1004
|
+
console.log(`storyboard: storyboards/${group.key}.${extension} kept, ${group.ran} of ${group.expected} scenarios ran. Record the whole feature to rewrite it${group.rerun ? `: TASK_E2E_UPDATE_BASELINES=1 ${group.rerun}` : '.'}`)
|
|
1005
|
+
continue
|
|
1006
|
+
}
|
|
1007
|
+
markdown.renderFeatureMarkdown(group.items.map(item => ({
|
|
1008
|
+
...item,
|
|
1009
|
+
failure: null,
|
|
1010
|
+
imageDir: path.join(global.codecept_dir, 'screenshots', 'base', item.board.baseDir)
|
|
1011
|
+
})), path.join(global.codecept_dir, 'storyboards', `${group.key}.${extension}`), { rerun: group.rerun })
|
|
1012
|
+
} catch (err) {
|
|
1013
|
+
console.error(`storyboard: Markdown rendering failed: ${err.message}`)
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
|
|
945
1018
|
event.dispatcher.on(event.test.passed, () => finish(true))
|
|
946
1019
|
event.dispatcher.on(event.test.failed, () => finish(false))
|
|
947
1020
|
event.dispatcher.on(event.all.after, () => {
|
|
948
1021
|
if (!global.codecept_dir) return
|
|
949
1022
|
try {
|
|
1023
|
+
renderFeatures()
|
|
950
1024
|
const stories = [...entries.values()]
|
|
951
1025
|
writeGallery(path.join(global.codecept_dir, '_output'), stories, format)
|
|
952
1026
|
if (process.env.TASK_E2E_UPDATE_BASELINES === '1' && !process.env.CI) {
|
package/src/markdown.js
CHANGED
|
@@ -99,26 +99,13 @@ function comparison (outFile, card, frame) {
|
|
|
99
99
|
]
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
const
|
|
109
|
-
const chunks = [
|
|
110
|
-
`# ${caption(board.scenario || board.feature || 'Storyboard')}`,
|
|
111
|
-
...(board.scenario && board.feature ? [`**${caption(board.featureKeyword || 'Feature')}:** ${caption(board.feature)}`] : []),
|
|
112
|
-
'<a name="storyboard-result"></a>',
|
|
113
|
-
`> [!${verdict === 'FAILED' ? 'caution' : verdict === 'PASSED' ? 'tip' : 'note'}] ${verdict}\n> ${summary}`
|
|
114
|
-
]
|
|
115
|
-
if (presentation.tableOfContents) {
|
|
116
|
-
chunks.push('**On this page**', [
|
|
117
|
-
'[Result](#storyboard-result)',
|
|
118
|
-
...chapters.map((card, index) => `[${caption(card.chapter)}](#storyboard-chapter-${index + 1})`),
|
|
119
|
-
'[Replay and source](#storyboard-replay)'
|
|
120
|
-
].join(' · '))
|
|
121
|
-
}
|
|
102
|
+
// The chapters, cards and failure evidence of one scenario. `level` is the
|
|
103
|
+
// heading depth of its chapters, `anchor` keeps their targets unique on a
|
|
104
|
+
// page that holds several scenarios.
|
|
105
|
+
function scenarioChunks (board, outFile, presentation, { imageDir, failure, level = 2, anchor = 'storyboard-chapter' } = {}) {
|
|
106
|
+
const heading = '#'.repeat(level)
|
|
107
|
+
const cards = cardsOf(board, imageDir)
|
|
108
|
+
const chunks = []
|
|
122
109
|
let pending = []
|
|
123
110
|
let chapterNumber = 0
|
|
124
111
|
const flush = () => {
|
|
@@ -129,11 +116,11 @@ function renderMarkdown (board, outFile, options = {}) {
|
|
|
129
116
|
if (card.chapter) {
|
|
130
117
|
flush()
|
|
131
118
|
chapterNumber++
|
|
132
|
-
chunks.push(`<a name="
|
|
119
|
+
chunks.push(`<a name="${anchor}-${chapterNumber}"></a>`, `${heading} ${caption(card.chapter).trim()}`)
|
|
133
120
|
}
|
|
134
121
|
if (failure && failure.frame && path.basename(card.file) === failure.frame.name) {
|
|
135
122
|
flush()
|
|
136
|
-
chunks.push(...comparison(outFile, card, failure.frame))
|
|
123
|
+
chunks.push(...comparison(outFile, card, failure.frame).map(chunk => chunk.replace(/^## /, `${heading} `)))
|
|
137
124
|
} else {
|
|
138
125
|
pending.push(card)
|
|
139
126
|
if (pending.length === presentation.columns) flush()
|
|
@@ -141,16 +128,98 @@ function renderMarkdown (board, outFile, options = {}) {
|
|
|
141
128
|
}
|
|
142
129
|
flush()
|
|
143
130
|
if (failure && failure.notReached && failure.notReached.length) {
|
|
144
|
-
chunks.push(
|
|
131
|
+
chunks.push(`${heading} Not reached`, failure.notReached.map(line => `- ${caption(sentence(line))}`).join('\n'))
|
|
145
132
|
}
|
|
133
|
+
return { chunks, cards }
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function verdictOf (failed, outcome) {
|
|
137
|
+
return failed || outcome === 'failed' ? 'FAILED' : outcome === 'passed' ? 'PASSED' : 'Outcome not recorded'
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function alert (verdict, summary) {
|
|
141
|
+
return `> [!${verdict === 'FAILED' ? 'caution' : verdict === 'PASSED' ? 'tip' : 'note'}] ${verdict}${summary ? `\n> ${summary}` : ''}`
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function write (outFile, chunks) {
|
|
145
|
+
fs.mkdirSync(path.dirname(outFile), { recursive: true })
|
|
146
|
+
fs.writeFileSync(outFile, chunks.join('\n\n') + '\n')
|
|
147
|
+
return outFile
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const CHECKS = 'Each screenshot is compared pixel by pixel with a reviewed reference image (tolerance: 0).'
|
|
151
|
+
|
|
152
|
+
function renderMarkdown (board, outFile, options = {}) {
|
|
153
|
+
const presentation = normalizeMarkdown(options.markdown === undefined ? board.markdown : options.markdown)
|
|
154
|
+
const failure = options.failure
|
|
155
|
+
const verdict = verdictOf(failure, options.outcome)
|
|
156
|
+
const cards = cardsOf(board, options.imageDir)
|
|
157
|
+
const chapters = cards.filter(card => card.chapter)
|
|
158
|
+
const summary = `${board.lines.length || board.panels.length} steps · ${cards.length} frames`
|
|
159
|
+
const chunks = [
|
|
160
|
+
`# ${caption(board.scenario || board.feature || 'Storyboard')}`,
|
|
161
|
+
...(board.scenario && board.feature ? [`**${caption(board.featureKeyword || 'Feature')}:** ${caption(board.feature)}`] : []),
|
|
162
|
+
'<a name="storyboard-result"></a>',
|
|
163
|
+
alert(verdict, summary)
|
|
164
|
+
]
|
|
165
|
+
if (presentation.tableOfContents) {
|
|
166
|
+
chunks.push('**On this page**', [
|
|
167
|
+
'[Result](#storyboard-result)',
|
|
168
|
+
...chapters.map((card, index) => `[${caption(card.chapter)}](#storyboard-chapter-${index + 1})`),
|
|
169
|
+
'[Replay and source](#storyboard-replay)'
|
|
170
|
+
].join(' · '))
|
|
171
|
+
}
|
|
172
|
+
chunks.push(...scenarioChunks(board, outFile, presentation, { imageDir: options.imageDir, failure }).chunks)
|
|
146
173
|
chunks.push('<a name="storyboard-replay"></a>', details('Replay this scenario · source and checks', [
|
|
147
174
|
...(board.rerun ? [codeBlock(board.rerun, 'shell')] : []),
|
|
148
175
|
...(board.file ? ['**Source**', codeBlock(board.file, 'text')] : []),
|
|
149
|
-
|
|
176
|
+
CHECKS
|
|
150
177
|
].join('\n\n'), presentation))
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
178
|
+
return write(outFile, chunks)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// One page for a whole feature file: each scenario that ran is a chapter of
|
|
182
|
+
// it, in the order it ran, and its own chapters sit one level below.
|
|
183
|
+
// `scenarios` items are { board, failure, outcome, imageDir }.
|
|
184
|
+
function renderFeatureMarkdown (scenarios, outFile, options = {}) {
|
|
185
|
+
if (!scenarios.length) throw new Error('storyboard: a feature page needs at least one scenario')
|
|
186
|
+
const first = scenarios[0].board
|
|
187
|
+
const presentation = normalizeMarkdown(options.markdown === undefined ? first.markdown : options.markdown)
|
|
188
|
+
const verdicts = scenarios.map(item => verdictOf(item.failure, item.outcome))
|
|
189
|
+
const verdict = verdicts.includes('FAILED') ? 'FAILED' : verdicts.every(item => item === 'PASSED') ? 'PASSED' : 'Outcome not recorded'
|
|
190
|
+
const bodies = scenarios.map((item, index) => scenarioChunks(item.board, outFile, presentation, {
|
|
191
|
+
imageDir: item.imageDir,
|
|
192
|
+
failure: item.failure,
|
|
193
|
+
level: 3,
|
|
194
|
+
anchor: `storyboard-chapter-${index + 1}`
|
|
195
|
+
}))
|
|
196
|
+
const steps = scenarios.reduce((total, item) => total + (item.board.lines.length || item.board.panels.length), 0)
|
|
197
|
+
const frames = bodies.reduce((total, body) => total + body.cards.length, 0)
|
|
198
|
+
const chunks = [
|
|
199
|
+
`# ${caption(first.feature || 'Storyboard')}`,
|
|
200
|
+
'<a name="storyboard-result"></a>',
|
|
201
|
+
alert(verdict, `${scenarios.length} ${scenarios.length === 1 ? 'scenario' : 'scenarios'} · ${steps} steps · ${frames} frames`)
|
|
202
|
+
]
|
|
203
|
+
if (presentation.tableOfContents) {
|
|
204
|
+
chunks.push('**On this page**', [
|
|
205
|
+
'[Result](#storyboard-result)',
|
|
206
|
+
...scenarios.map((item, index) => `[${caption(item.board.scenario)}](#storyboard-scenario-${index + 1})`),
|
|
207
|
+
'[Replay and source](#storyboard-replay)'
|
|
208
|
+
].join(' · '))
|
|
209
|
+
}
|
|
210
|
+
scenarios.forEach((item, index) => {
|
|
211
|
+
chunks.push(`<a name="storyboard-scenario-${index + 1}"></a>`, `## ${caption(item.board.scenario)}`)
|
|
212
|
+
if (verdicts[index] === 'FAILED') chunks.push(alert('FAILED'))
|
|
213
|
+
chunks.push(...bodies[index].chunks)
|
|
214
|
+
})
|
|
215
|
+
const commands = scenarios.filter(item => item.board.rerun)
|
|
216
|
+
chunks.push('<a name="storyboard-replay"></a>', details('Replay this feature · source and checks', [
|
|
217
|
+
...(options.rerun ? [codeBlock(options.rerun, 'shell')] : []),
|
|
218
|
+
...(commands.length ? ['**One scenario**', ...commands.map(item => `${caption(item.board.scenario)}\n\n${codeBlock(item.board.rerun, 'shell')}`)] : []),
|
|
219
|
+
...(first.file ? ['**Source**', codeBlock(first.file, 'text')] : []),
|
|
220
|
+
CHECKS
|
|
221
|
+
].join('\n\n'), presentation))
|
|
222
|
+
return write(outFile, chunks)
|
|
154
223
|
}
|
|
155
224
|
|
|
156
|
-
module.exports = { renderMarkdown, text, codeBlock, relativeLink }
|
|
225
|
+
module.exports = { renderMarkdown, renderFeatureMarkdown, text, codeBlock, relativeLink }
|