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): skip stack trace playwright/src lines only under tests (#5594)

Max Schmitt070cfdcdb864
diff --git a/src/utils/stackTrace.ts b/src/utils/stackTrace.ts
index b650935c7e..69aa768fbb 100644
--- a/src/utils/stackTrace.ts
+++ b/src/utils/stackTrace.ts
@@ -41,7 +41,7 @@ const PW_LIB_DIRS = [
'playwright-chromium',
'playwright-firefox',
'playwright-webkit',
-].map(packageName => path.join(packageName, 'lib'));
+].map(packageName => path.join('node_modules', packageName, 'lib'));
export function captureStackTrace(): { stack: string, frames: StackFrame[] } {
const stack = new Error().stack!;
@@ -56,7 +56,7 @@ export function captureStackTrace(): { stack: string, frames: StackFrame[] } {
if (PW_LIB_DIRS.some(libDir => fileName.includes(libDir)))
continue;
// for tests.
- if (fileName.includes(path.join('playwright', 'src')))
+ if (isUnderTest() && fileName.includes(path.join('playwright', 'src')))
continue;
if (isUnderTest() && fileName.includes(path.join('playwright', 'test', 'coverage.js')))
continue;
diff --git a/test/fixtures.spec.ts b/test/fixtures.spec.ts
index 475176618a..78c0bb05a8 100644
--- a/test/fixtures.spec.ts
+++ b/test/fixtures.spec.ts
@@ -19,6 +19,7 @@ import { folio, RemoteServer } from './remoteServer.fixture';
import { execSync } from 'child_process';
import path from 'path';
import * as stackTrace from '../src/utils/stackTrace';
+import { setUnderTest } from '../src/utils/utils';
type FixturesFixtures = {
connectedRemoteServer: RemoteServer;
@@ -129,6 +130,7 @@ describe('fixtures', (suite, { platform, headful }) => {
});
it('caller file path', async ({}) => {
+ setUnderTest();
const callme = require('./fixtures/callback');
const filePath = callme(() => {
return stackTrace.getCallerFilePath(path.join(__dirname, 'fixtures') + path.sep);