frontend tests: add helper.logDebugMsg function to help get information from tests that do not have support for console.json on SauceLabs

This commit is contained in:
webzwo0i 2021-07-16 20:41:35 +02:00
parent ca4cc2d7c0
commit c228283c17
4 changed files with 23 additions and 0 deletions

View file

@ -226,3 +226,15 @@ helper.clearPad = async () => {
await helper.waitForPromise(() => helper.commits.length > commitsBefore);
});
};
/**
* Writes to an (hidden) element which is dropped into the console output of a workflow run
*
* This is useful for debugging failed tests when there is no console log output available on
* SauceLabs (e.g. Safari)
*
*/
helper.logDebugMsg = (msg) => {
const elem = $('#debuglogs');
elem.append(`\n${msg}`);
};

View file

@ -8,6 +8,7 @@
</head>
<body>
<div id="console"></div>
<div id="debuglogs"></div>
<div id="split-view">
<div id="mocha"></div>
<div id="separator"></div>

View file

@ -13,6 +13,10 @@ body {
display: none;
}
#debuglogs {
display: none;
}
#split-view {
width: 100%;
height: 100%;

View file

@ -54,6 +54,11 @@ const sauceTestWorker = async.queue(async ({name, pfx, testSettings}) => {
.setFirefoxOptions(firefoxOptions)
.build();
const url = `https://saucelabs.com/jobs/${(await driver.getSession()).getId()}`;
const debugOutput = () => {
const console = document.getElementById('debuglogs'); // eslint-disable-line no-undef
if (console == null) return '';
return console.innerText;
};
try {
await driver.get('http://localhost:9001/tests/frontend/');
log(`Remote sauce test started! ${url}`, pfx);
@ -89,6 +94,7 @@ const sauceTestWorker = async.queue(async ({name, pfx, testSettings}) => {
}
} finally {
log(`Remote sauce test finished! ${url}`, pfx);
log(`Debug logs of ${pfx}: ${await driver.executeScript(debugOutput)}`);
await driver.quit();
}
}, 6); // run 6 tests in parrallel