From 3367ebd9683c11a36d8b400b1cecbeda0e915e21 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Tue, 11 Oct 2022 11:33:33 -0700 Subject: [PATCH] cherry-pick(#17999): chore: don't fail on undefined video/trace (#18001) --- packages/playwright-test/src/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/playwright-test/src/index.ts b/packages/playwright-test/src/index.ts index 1e7b82bdde811..e00fc8ef57803 100644 --- a/packages/playwright-test/src/index.ts +++ b/packages/playwright-test/src/index.ts @@ -579,7 +579,9 @@ type ParsedStackTrace = { apiName: string; }; -export function normalizeVideoMode(video: VideoMode | 'retry-with-video' | { mode: VideoMode }) { +export function normalizeVideoMode(video: VideoMode | 'retry-with-video' | { mode: VideoMode } | undefined): VideoMode { + if (!video) + return 'off'; let videoMode = typeof video === 'string' ? video : video.mode; if (videoMode === 'retry-with-video') videoMode = 'on-first-retry'; @@ -590,7 +592,9 @@ export function shouldCaptureVideo(videoMode: VideoMode, testInfo: TestInfo) { return (videoMode === 'on' || videoMode === 'retain-on-failure' || (videoMode === 'on-first-retry' && testInfo.retry === 1)); } -export function normalizeTraceMode(trace: TraceMode | 'retry-with-trace' | { mode: TraceMode }) { +export function normalizeTraceMode(trace: TraceMode | 'retry-with-trace' | { mode: TraceMode } | undefined): TraceMode { + if (!trace) + return 'off'; let traceMode = typeof trace === 'string' ? trace : trace.mode; if (traceMode === 'retry-with-trace') traceMode = 'on-first-retry';