Skip to content

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

chore: print full stacks when PWDEBUGIMPL is set (#16113)

Dmitry Gozman5481e25015ed
diff --git a/packages/playwright-core/src/utils/stackTrace.ts b/packages/playwright-core/src/utils/stackTrace.ts
index d4631dd960..641ab1180a 100644
--- a/packages/playwright-core/src/utils/stackTrace.ts
+++ b/packages/playwright-core/src/utils/stackTrace.ts
@@ -83,9 +83,9 @@ export function captureStackTrace(rawStack?: string): ParsedStackTrace {
const { frame, fileName } = parseStackTraceLine(line);
if (!frame || !frame.file || !fileName)
return null;
- if (isInternalFileName(frame.file, frame.function))
+ if (!process.env.PWDEBUGIMPL && isInternalFileName(frame.file, frame.function))
return null;
- if (isTesting && fileName.includes(COVERAGE_PATH))
+ if (!process.env.PWDEBUGIMPL && isTesting && fileName.includes(COVERAGE_PATH))
return null;
const inCore = fileName.startsWith(CORE_LIB) || fileName.startsWith(CORE_SRC);
const parsed: ParsedFrame = {
@@ -109,7 +109,8 @@ export function captureStackTrace(rawStack?: string): ParsedStackTrace {
if (parsedFrames[i].inCore && !parsedFrames[i + 1].inCore) {
const frame = parsedFrames[i].frame;
apiName = normalizeAPIName(frame.function);
- parsedFrames = parsedFrames.slice(i + 1);
+ if (!process.env.PWDEBUGIMPL)
+ parsedFrames = parsedFrames.slice(i + 1);
break;
}
}
@@ -125,6 +126,8 @@ export function captureStackTrace(rawStack?: string): ParsedStackTrace {
// Hide all test runner and library frames in the user stack (event handlers produce them).
parsedFrames = parsedFrames.filter((f, i) => {
+ if (process.env.PWDEBUGIMPL)
+ return true;
if (f.frame.file.startsWith(TEST_DIR_SRC) || f.frame.file.startsWith(TEST_DIR_LIB))
return false;
if (i && f.frame.file.startsWith(CORE_DIR))
diff --git a/packages/playwright-test/src/util.ts b/packages/playwright-test/src/util.ts
index 9fcd51208e..d43ea19bb7 100644
--- a/packages/playwright-test/src/util.ts
+++ b/packages/playwright-test/src/util.ts
@@ -35,6 +35,9 @@ const EXPECT_PATH_IMPL = require.resolve('./expectBundleImpl');
const PLAYWRIGHT_TEST_PATH = path.join(__dirname, '..');
function filterStackTrace(e: Error) {
+ if (process.env.PWDEBUGIMPL)
+ return;
+
// This method filters internal stack frames using Error.prepareStackTrace
// hook. Read more about the hook: https://v8.dev/docs/stack-trace-api
//