fix(inspector): skip stack trace playwright/src lines only under tests (#5594)

This commit is contained in:
Max Schmitt 2021-02-24 20:34:48 +01:00 committed by GitHub
parent aa94dfbcb6
commit 070cfdcdb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -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;

View File

@ -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);