MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / persistStep

Function persistStep

lib/plugin/screenshot.js:319–350  ·  view source on GitHub ↗
(step)

Source from the content-addressed store, hash-verified

317 }
318
319 async function persistStep(step) {
320 if (stepNum === -1) return
321 if (savedStep === step) return
322 if (scenarioFailed) return
323 if (step.metaStep && step.metaStep.title === 'BeforeSuite') return
324 if (!currentTest) return
325 if (!stepFilter(step)) return
326 if (isStepIgnored(step, options.ignoreSteps)) return
327
328 const fileName = `${String(stepNum).padStart(4, '0')}.png`
329 if (step.status === 'failed') scenarioFailed = true
330 stepNum++
331 slides[fileName] = step
332
333 const helper = getBrowserHelper()
334 if (!helper || typeof helper.saveScreenshot !== 'function') return
335
336 try {
337 const screenshotPath = path.join(dir, fileName)
338 await helper.saveScreenshot(screenshotPath, options.fullPageScreenshots)
339 step.artifacts = step.artifacts || {}
340 step.artifacts.screenshot = screenshotPath
341
342 currentTest.artifacts = currentTest.artifacts || {}
343 currentTest.artifacts.screenshots = currentTest.artifacts.screenshots || []
344 currentTest.artifacts.screenshots.push(screenshotPath)
345 } catch (err) {
346 output.plugin('screenshot', `Can't save step screenshot: ${err.message}`)
347 } finally {
348 savedStep = step
349 }
350 }
351
352 function persist(test) {
353 if (!Object.keys(slides).length) return

Callers 1

wireSlidesFunction · 0.70

Calls 4

getBrowserHelperFunction · 0.90
pushMethod · 0.80
isStepIgnoredFunction · 0.70
saveScreenshotMethod · 0.45

Tested by

no test coverage detected