Skip to content

Commit

Permalink
Capture browser logs on test failure (#22670)
Browse files Browse the repository at this point in the history
* Capture browser logs

* spit out in logs, simulate failure to test

* remove leftover code

* simulate failure

* Remove forced failure
  • Loading branch information
stacey-gammon authored Sep 13, 2018
1 parent 9847e82 commit 041a475
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/functional/apps/dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default function ({ getService, loadTestFile, getPageObjects }) {
loadTestFile(require.resolve('./_dashboard_filter_bar'));

// TODO: unskip when https://github.com/elastic/kibana/issues/20442 is fixed
//loadTestFile(require.resolve('./_dashboard_filtering'));
// loadTestFile(require.resolve('./_dashboard_filtering'));

loadTestFile(require.resolve('./_panel_expand_toggle'));
loadTestFile(require.resolve('./_dashboard_grid'));
Expand Down
13 changes: 12 additions & 1 deletion test/functional/services/failure_debugging.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,29 @@ export async function FailureDebuggingProvider({ getService }) {
await writeFileAsync(htmlOutputFileName, pageSource);
}

async function logBrowserConsole() {
const browserLogs = await remote.getLogsFor('browser');
const browserOutput = browserLogs.reduce((acc, log) => acc += `${log.message.replace(/\\n/g, '\n')}\n`, '');
log.info(`Browser output is: ${browserOutput}`);
}

async function onFailure(error, test) {
// Replace characters in test names which can't be used in filenames, like *
const name = test.fullTitle().replace(/([^ a-zA-Z0-9-]+)/g, '_');

await Promise.all([
screenshots.takeForFailure(name),
logCurrentUrl(),
savePageHtml(name)
savePageHtml(name),
logBrowserConsole(),
]);
}

lifecycle
.on('testFailure', onFailure)
.on('testHookFailure', onFailure);

return {
logBrowserConsole
};
}

0 comments on commit 041a475

Please sign in to comment.