mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix: filter out pwt stacks correctly (#20158)
Fixes https://github.com/microsoft/playwright/issues/20155
This commit is contained in:
parent
9a64597d74
commit
df05c00da3
@ -30,10 +30,13 @@ export function rewriteErrorMessage<E extends Error>(e: E, newMessage: string):
|
|||||||
const CORE_DIR = path.resolve(__dirname, '..', '..');
|
const CORE_DIR = path.resolve(__dirname, '..', '..');
|
||||||
const CORE_LIB = path.join(CORE_DIR, 'lib');
|
const CORE_LIB = path.join(CORE_DIR, 'lib');
|
||||||
const CORE_SRC = path.join(CORE_DIR, 'src');
|
const CORE_SRC = path.join(CORE_DIR, 'src');
|
||||||
const TEST_DIR_SRC = path.resolve(CORE_DIR, '..', 'playwright-test');
|
|
||||||
const TEST_DIR_LIB = path.resolve(CORE_DIR, '..', '@playwright', 'test');
|
|
||||||
const COVERAGE_PATH = path.join(CORE_DIR, '..', '..', 'tests', 'config', 'coverage.js');
|
const COVERAGE_PATH = path.join(CORE_DIR, '..', '..', 'tests', 'config', 'coverage.js');
|
||||||
|
|
||||||
|
const stackIgnoreFilters = [
|
||||||
|
(frame: StackFrame) => frame.file.startsWith(CORE_DIR),
|
||||||
|
];
|
||||||
|
export const addStackIgnoreFilter = (filter: (frame: StackFrame) => boolean) => stackIgnoreFilters.push(filter);
|
||||||
|
|
||||||
export type StackFrame = {
|
export type StackFrame = {
|
||||||
file: string,
|
file: string,
|
||||||
line?: number,
|
line?: number,
|
||||||
@ -125,9 +128,7 @@ export function captureStackTrace(rawStack?: string): ParsedStackTrace {
|
|||||||
parsedFrames = parsedFrames.filter((f, i) => {
|
parsedFrames = parsedFrames.filter((f, i) => {
|
||||||
if (process.env.PWDEBUGIMPL)
|
if (process.env.PWDEBUGIMPL)
|
||||||
return true;
|
return true;
|
||||||
if (f.frame.file.startsWith(TEST_DIR_SRC) || f.frame.file.startsWith(TEST_DIR_LIB))
|
if (stackIgnoreFilters.some(filter => filter(f.frame)))
|
||||||
return false;
|
|
||||||
if (f.frame.file.startsWith(CORE_DIR))
|
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
@ -18,7 +18,7 @@ import * as fs from 'fs';
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import type { APIRequestContext, BrowserContext, BrowserContextOptions, LaunchOptions, Page, Tracing, Video } from 'playwright-core';
|
import type { APIRequestContext, BrowserContext, BrowserContextOptions, LaunchOptions, Page, Tracing, Video } from 'playwright-core';
|
||||||
import * as playwrightLibrary from 'playwright-core';
|
import * as playwrightLibrary from 'playwright-core';
|
||||||
import { createGuid, debugMode, removeFolders } from 'playwright-core/lib/utils';
|
import { createGuid, debugMode, removeFolders, addStackIgnoreFilter } from 'playwright-core/lib/utils';
|
||||||
import type { Fixtures, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, ScreenshotMode, TestInfo, TestType, TraceMode, VideoMode } from '../types/test';
|
import type { Fixtures, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, ScreenshotMode, TestInfo, TestType, TraceMode, VideoMode } from '../types/test';
|
||||||
import { store as _baseStore } from './store';
|
import { store as _baseStore } from './store';
|
||||||
import type { TestInfoImpl } from './testInfo';
|
import type { TestInfoImpl } from './testInfo';
|
||||||
@ -29,6 +29,8 @@ export { addRunnerPlugin as _addRunnerPlugin } from './plugins';
|
|||||||
export const _baseTest: TestType<{}, {}> = rootTestType.test;
|
export const _baseTest: TestType<{}, {}> = rootTestType.test;
|
||||||
export const store = _baseStore;
|
export const store = _baseStore;
|
||||||
|
|
||||||
|
addStackIgnoreFilter((frame: StackFrame) => frame.file.startsWith(path.dirname(require.resolve('../package.json'))));
|
||||||
|
|
||||||
if ((process as any)['__pw_initiator__']) {
|
if ((process as any)['__pw_initiator__']) {
|
||||||
const originalStackTraceLimit = Error.stackTraceLimit;
|
const originalStackTraceLimit = Error.stackTraceLimit;
|
||||||
Error.stackTraceLimit = 200;
|
Error.stackTraceLimit = 200;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user