Skip to content

Commit

Permalink
cherry-pick(release-1.9): stacktrace with browser specific NPM package (
Browse files Browse the repository at this point in the history
microsoft#5589) (microsoft#5598)

This cherry-picks fefe37e

Co-authored-by: Max Schmitt <max@schmitt.mx>
  • Loading branch information
aslushnikov and mxschmitt authored Feb 24, 2021
1 parent 37bd44f commit 9e69146
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/utils/stackTrace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [];
Expand All @@ -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')))
Expand Down

0 comments on commit 9e69146

Please sign in to comment.