Skip to content

Commit 210808a

Browse files
Liviu RauDevtools-frontend LUCI CQ
authored andcommitted
Take frontend/target screenshots at failure time
In instrumented test function we will preserve the screenshot error too. Bug: 407460244 Change-Id: I870cbaccce2958639f7ab6d65e82a628fb1436f7 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6429833 Auto-Submit: Liviu Rau <liviurau@chromium.org> Commit-Queue: Simon Zünd <szuend@chromium.org> Reviewed-by: Simon Zünd <szuend@chromium.org>
1 parent f7ef7f1 commit 210808a

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

test/e2e_non_hosted/conductor/mocha-interface-helpers.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@ async function createScreenshotError(test: Mocha.Runnable|undefined, error: Erro
2525
console.error('Missing browsing state. Unable to take screenshots for the error:', error);
2626
return error;
2727
}
28-
const sate = test.parent.state;
28+
return await screenshotError(test.parent.state, error);
29+
}
30+
31+
export async function screenshotError(state: E2E.State, error: Error) {
2932
console.error('Taking screenshots for the error:', error);
3033
if (!TestConfig.debug) {
3134
try {
3235
const screenshotTimeout = 5_000;
3336
let timer: ReturnType<typeof setTimeout>;
3437
const {target, frontend} = await Promise.race([
35-
takeScreenshots(sate).then(result => {
38+
takeScreenshots(state).then(result => {
3639
clearTimeout(timer);
3740
return result;
3841
}),
@@ -89,7 +92,7 @@ export function makeInstrumentedTestFunction(fn: Mocha.AsyncFunc, label: string)
8992
if (abortController.signal.aborted) {
9093
return;
9194
}
92-
reject(await createScreenshotError(this.test, err));
95+
reject(err instanceof ScreenshotError ? err : await createScreenshotError(this.test, err));
9396
})
9497
.finally(() => {
9598
clearTimeout(t);

test/e2e_non_hosted/conductor/state-provider.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import {type BrowserWrapper, DEFAULT_BROWSER_SETTINGS, Launcher} from '../shared
1313
import {DEFAULT_DEVTOOLS_SETTINGS, setupDevToolsPage} from '../shared/frontend-helper.js';
1414
import {setupInspectedPage} from '../shared/target-helper.js';
1515

16+
import {screenshotError} from './mocha-interface-helpers.js';
17+
1618
const DEFAULT_SETTINGS = {
1719
...DEFAULT_BROWSER_SETTINGS,
1820
...DEFAULT_DEVTOOLS_SETTINGS
@@ -38,6 +40,8 @@ export class StateProvider {
3840
// eslint-disable-next-line no-debugger
3941
debugger; // If you're paused here while debugging, stepping into the next line will step into your test.
4042
return await testFn.call(context, state);
43+
} catch (e) {
44+
throw await screenshotError(state, e);
4145
} finally {
4246
await browsingContext.close();
4347
dumpCollectedErrors();

0 commit comments

Comments
 (0)