Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function SpecXUnit( runner ) {
mochawesome.call( this, runner, {
reporterOptions: {
overwrite: false,
html: false,
json: true,
reportDir: 'ma-reports',
},
} );
XUnit.call( this, runner, { reporterOptions: { output: reportName } } );
}
async function takeScreenshot (browser, test) {
try {
let base64png = await browser.takeScreenshot();
addContext(test, {
title: 'Browser screenshot',
value: `data:image/png;base64,${base64png}`
});
} catch {
error('Could not take browser screenshot.');
}
}
async function getBrowserLog (browser, test) {
try {
let consoleOutput = '';
let browserLog = await browser.manage().logs().get('browser');
if (browserLog.length > 0) {
info('Browser console output:');
browserLog.forEach(log => {
consoleOutput += `${log.message}\n`;
error(log.message);
});
}
if (consoleOutput.length) {
addContext(test, {
title: 'Browser console output',
value: consoleOutput
});
}
} catch {
error('Could not get browser console output.');
}
}