cherry-pick(release-1.9): stacktrace with browser specific NPM package (#5589) (#5598)

This cherry-picks fefe37e96f

Co-authored-by: Max Schmitt <max@schmitt.mx>
This commit is contained in:
Andrey Lushnikov 2021-02-24 13:22:01 -08:00 committed by GitHub
parent 37bd44f552
commit 9e69146a6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,6 +36,13 @@ export function rewriteErrorMessage(e: Error, newMessage: string): Error {
return e; 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[] } { export function captureStackTrace(): { stack: string, frames: StackFrame[] } {
const stack = new Error().stack!; const stack = new Error().stack!;
const frames: StackFrame[] = []; const frames: StackFrame[] = [];
@ -46,7 +53,7 @@ export function captureStackTrace(): { stack: string, frames: StackFrame[] } {
if (frame.file.startsWith('internal')) if (frame.file.startsWith('internal'))
continue; continue;
const fileName = path.resolve(process.cwd(), frame.file); 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; continue;
// for tests. // for tests.
if (fileName.includes(path.join('playwright', 'src'))) if (fileName.includes(path.join('playwright', 'src')))