Skip to content

Commit 1196ac6

Browse files
cherry-pick(release-1.9): skip stack trace playwright/src lines only under tests (#5594) (#5599)
This cherry-picks 070cfdc Co-authored-by: Max Schmitt <[email protected]>
1 parent 9e69146 commit 1196ac6

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/utils/stackTrace.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const PW_LIB_DIRS = [
4141
'playwright-chromium',
4242
'playwright-firefox',
4343
'playwright-webkit',
44-
].map(packageName => path.join(packageName, 'lib'));
44+
].map(packageName => path.join('node_modules', packageName, 'lib'));
4545

4646
export function captureStackTrace(): { stack: string, frames: StackFrame[] } {
4747
const stack = new Error().stack!;
@@ -56,7 +56,7 @@ export function captureStackTrace(): { stack: string, frames: StackFrame[] } {
5656
if (PW_LIB_DIRS.some(libDir => fileName.includes(libDir)))
5757
continue;
5858
// for tests.
59-
if (fileName.includes(path.join('playwright', 'src')))
59+
if (isUnderTest() && fileName.includes(path.join('playwright', 'src')))
6060
continue;
6161
if (isUnderTest() && fileName.includes(path.join('playwright', 'test', 'coverage.js')))
6262
continue;

test/fixtures.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { folio, RemoteServer } from './remoteServer.fixture';
1919
import { execSync } from 'child_process';
2020
import path from 'path';
2121
import * as stackTrace from '../src/utils/stackTrace';
22+
import { setUnderTest } from '../src/utils/utils';
2223

2324
type FixturesFixtures = {
2425
connectedRemoteServer: RemoteServer;
@@ -129,6 +130,7 @@ describe('fixtures', (suite, { platform, headful }) => {
129130
});
130131

131132
it('caller file path', async ({}) => {
133+
setUnderTest();
132134
const callme = require('./fixtures/callback');
133135
const filePath = callme(() => {
134136
return stackTrace.getCallerFilePath(path.join(__dirname, 'fixtures') + path.sep);

0 commit comments

Comments
 (0)