From 9e69146a6e95627d882cb027dfa772b2804b68b4 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Wed, 24 Feb 2021 13:22:01 -0800 Subject: [PATCH] cherry-pick(release-1.9): stacktrace with browser specific NPM package (#5589) (#5598) This cherry-picks fefe37e96f61769180d145a1aa7744caac3b6309 Co-authored-by: Max Schmitt --- 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')))