Skip to content

Commit

Permalink
fix: stepByStep report doesn't sync properly (#4413)
Browse files Browse the repository at this point in the history
* fix: stepByStep report doesnt sync properly

* fix: wrong event is called

* fix: failed when there is Beforesuite

* fix: error with aftersuite
  • Loading branch information
kobenguyent authored Jun 28, 2024
1 parent c5ab8dd commit 7235135
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/plugin/stepByStepReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ module.exports = function (config) {
const pad = '0000'
const reportDir = config.output ? path.resolve(global.codecept_dir, config.output) : defaultConfig.output

event.dispatcher.on(event.suite.before, (suite) => {
stepNum = -1
})

event.dispatcher.on(event.test.before, (test) => {
const sha256hash = crypto
.createHash('sha256')
Expand All @@ -106,7 +110,9 @@ module.exports = function (config) {
recorder.add('screenshot of failed test', async () => persistStep(step), true)
})

event.dispatcher.on(event.step.after, persistStep)
event.dispatcher.on(event.step.after, (step) => {
recorder.add('screenshot of step of test', async () => persistStep(step), true)
})

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

async function persistStep(step) {
if (stepNum === -1) return // Ignore steps from BeforeSuite function
if (isStepIgnored(step)) return
if (savedStep === step) return // already saved
// Ignore steps from BeforeSuite function
if (scenarioFailed && config.disableScreenshotOnFail) return
if (step.metaStep && step.metaStep.name === 'BeforeSuite') return
if (!step.test) return // Ignore steps from AfterSuite

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

0 comments on commit 7235135

Please # to comment.