mirror of
				https://github.com/microsoft/playwright.git
				synced 2025-06-26 21:40:17 +00:00 
			
		
		
		
	fix(inspector): skip stack trace playwright/src lines only under tests (#5594)
This commit is contained in:
		
							parent
							
								
									aa94dfbcb6
								
							
						
					
					
						commit
						070cfdcdb8
					
				@ -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;
 | 
			
		||||
 | 
			
		||||
@ -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);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user