Skip to content

Commit 7235135

Browse files
authored
fix: stepByStep report doesn't sync properly (#4413)
* fix: stepByStep report doesnt sync properly * fix: wrong event is called * fix: failed when there is Beforesuite * fix: error with aftersuite
1 parent c5ab8dd commit 7235135

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Diff for: lib/plugin/stepByStepReport.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ module.exports = function (config) {
8888
const pad = '0000'
8989
const reportDir = config.output ? path.resolve(global.codecept_dir, config.output) : defaultConfig.output
9090

91+
event.dispatcher.on(event.suite.before, (suite) => {
92+
stepNum = -1
93+
})
94+
9195
event.dispatcher.on(event.test.before, (test) => {
9296
const sha256hash = crypto
9397
.createHash('sha256')
@@ -106,7 +110,9 @@ module.exports = function (config) {
106110
recorder.add('screenshot of failed test', async () => persistStep(step), true)
107111
})
108112

109-
event.dispatcher.on(event.step.after, persistStep)
113+
event.dispatcher.on(event.step.after, (step) => {
114+
recorder.add('screenshot of step of test', async () => persistStep(step), true)
115+
})
110116

111117
event.dispatcher.on(event.test.passed, (test) => {
112118
if (!config.deleteSuccessful) return persist(test)
@@ -147,11 +153,13 @@ module.exports = function (config) {
147153
})
148154

149155
async function persistStep(step) {
156+
if (stepNum === -1) return // Ignore steps from BeforeSuite function
150157
if (isStepIgnored(step)) return
151158
if (savedStep === step) return // already saved
152159
// Ignore steps from BeforeSuite function
153160
if (scenarioFailed && config.disableScreenshotOnFail) return
154161
if (step.metaStep && step.metaStep.name === 'BeforeSuite') return
162+
if (!step.test) return // Ignore steps from AfterSuite
155163

156164
const fileName = `${pad.substring(0, pad.length - stepNum.toString().length) + stepNum.toString()}.png`
157165
if (step.status === 'failed') {

0 commit comments

Comments
 (0)