From fefe37e96f61769180d145a1aa7744caac3b6309 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Wed, 24 Feb 2021 17:08:27 +0100 Subject: [PATCH] fix(inspector): stacktrace with browser specific NPM package (#5589) --- src/utils/stackTrace.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/utils/stackTrace.ts b/src/utils/stackTrace.ts index da7d7b151f..b650935c7e 100644 --- a/src/utils/stackTrace.ts +++ b/src/utils/stackTrace.ts @@ -36,6 +36,13 @@ export function rewriteErrorMessage(e: Error, newMessage: string): Error { return e; } +const PW_LIB_DIRS = [ + 'playwright', + 'playwright-chromium', + 'playwright-firefox', + 'playwright-webkit', +].map(packageName => path.join(packageName, 'lib')); + export function captureStackTrace(): { stack: string, frames: StackFrame[] } { const stack = new Error().stack!; const frames: StackFrame[] = []; @@ -46,7 +53,7 @@ export function captureStackTrace(): { stack: string, frames: StackFrame[] } { if (frame.file.startsWith('internal')) continue; const fileName = path.resolve(process.cwd(), frame.file); - if (fileName.includes(path.join('playwright', 'lib'))) + if (PW_LIB_DIRS.some(libDir => fileName.includes(libDir))) continue; // for tests. if (fileName.includes(path.join('playwright', 'src')))