Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (test.state === 'failed' || (test.state === 'passed' && config.saveAllVideos)) {
const filePath = path.resolve(this.recordingPath, this.frameNr.toString().padStart(4, '0') + '.png');
try {
browser.saveScreenshot(filePath);
helpers.debugLog('- Screenshot!!\n');
} catch (e) {
fs.writeFile(filePath, notAvailableImage, 'base64');
helpers.debugLog('- Screenshot not available...\n');
}
const videoPath = path.resolve(config.outputDir, this.testname + '.mp4');
this.videos.push(videoPath);
if (config.usingAllure) {
allureReporter.addAttachment('Execution video', videoPath, 'video/mp4');
}
const command = `"${ffmpegPath}" -y -r 10 -i "${this.recordingPath}/%04d.png" -vcodec libx264` +
` -crf 32 -pix_fmt yuv420p -vf "scale=1200:trunc(ow/a/2)*2","setpts=${config.videoSlowdownMultiplier}.0*PTS"` +
` "${path.resolve(config.outputDir, this.testname)}.mp4"`;
helpers.debugLog(`ffmpeg command: ${command}\n`);
this.ffmpegCommands.push(command);
}
}