(step, stepData, stepPrefix)
| 288 | } |
| 289 | |
| 290 | async function captureArtifactsForStep(step, stepData, stepPrefix) { |
| 291 | if (!step.artifacts) { |
| 292 | step.artifacts = {} |
| 293 | } |
| 294 | |
| 295 | let browserAvailable = true |
| 296 | |
| 297 | try { |
| 298 | try { |
| 299 | if (helper.grabCurrentUrl) { |
| 300 | const url = await helper.grabCurrentUrl() |
| 301 | stepData.meta.url = url |
| 302 | currentUrl = url |
| 303 | } |
| 304 | } catch (err) { |
| 305 | browserAvailable = false |
| 306 | output.debug(`aiTrace: Browser unavailable, partial artifact capture: ${err.message}`) |
| 307 | } |
| 308 | |
| 309 | let preExistingScreenshot = false |
| 310 | if (step.artifacts?.screenshot) { |
| 311 | const screenshotPath = path.isAbsolute(step.artifacts.screenshot) |
| 312 | ? step.artifacts.screenshot |
| 313 | : path.resolve(dir, step.artifacts.screenshot) |
| 314 | const screenshotFile = path.basename(screenshotPath) |
| 315 | stepData.artifacts.screenshot = screenshotFile |
| 316 | step.artifacts.screenshot = screenshotPath |
| 317 | preExistingScreenshot = true |
| 318 | |
| 319 | if (!fs.existsSync(screenshotPath)) { |
| 320 | try { |
| 321 | await helper.saveScreenshot(screenshotPath, config.fullPageScreenshots) |
| 322 | } catch (err) { |
| 323 | output.debug(`aiTrace: Could not save screenshot: ${err.message}`) |
| 324 | } |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | const captured = await captureSnapshot(helper, { |
| 329 | dir, |
| 330 | prefix: stepPrefix, |
| 331 | fullPage: config.fullPageScreenshots, |
| 332 | captureHTML: config.captureHTML && browserAvailable, |
| 333 | captureARIA: config.captureARIA && browserAvailable, |
| 334 | captureBrowserLogs: config.captureBrowserLogs && browserAvailable, |
| 335 | captureStorage: false, |
| 336 | }) |
| 337 | |
| 338 | if (!preExistingScreenshot && captured.screenshot) { |
| 339 | stepData.artifacts.screenshot = captured.screenshot |
| 340 | step.artifacts.screenshot = path.join(dir, captured.screenshot) |
| 341 | } |
| 342 | if (step.artifacts?.html) { |
| 343 | stepData.artifacts.html = step.artifacts.html |
| 344 | } else if (captured.html) { |
| 345 | stepData.artifacts.html = captured.html |
| 346 | } |
| 347 | if (captured.aria) stepData.artifacts.aria = captured.aria |
no test coverage detected