Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: stepByStep report doesn't sync properly #4413

Merged
merged 4 commits into from
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading