fix(inspector): stacktrace with browser specific NPM package (#5589)

This commit is contained in:
Max Schmitt 2021-02-24 17:08:27 +01:00 committed by GitHub
parent 48c237b3cf
commit fefe37e96f
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')))