Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

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

Max Schmittfefe37e96f61
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')))