Skip to content

Commit

Permalink
fix(inspector): stacktrace with browser specific NPM package (microso…
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt authored Feb 24, 2021
1 parent 48c237b commit fefe37e
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 fefe37e

Please sign in to comment.