mirror of
https://github.com/microsoft/playwright.git
synced 2024-09-20 00:41:16 +03:00
chore: fix(stack): ignore stack frames inside whole core (#11935)
This commit is contained in:
parent
9f35a97a55
commit
1b3c7c03b6
@ -31,10 +31,8 @@ export function rewriteErrorMessage<E extends Error>(e: E, newMessage: string):
|
|||||||
}
|
}
|
||||||
|
|
||||||
const CORE_DIR = path.resolve(__dirname, '..', '..');
|
const CORE_DIR = path.resolve(__dirname, '..', '..');
|
||||||
const CLIENT_LIB = path.join(CORE_DIR, 'lib', 'client');
|
const CORE_LIB = path.join(CORE_DIR, 'lib');
|
||||||
const CLIENT_SRC = path.join(CORE_DIR, 'src', 'client');
|
const CORE_SRC = path.join(CORE_DIR, 'src');
|
||||||
const UTIL_LIB = path.join(CORE_DIR, 'lib', 'util');
|
|
||||||
const UTIL_SRC = path.join(CORE_DIR, 'src', 'util');
|
|
||||||
const TEST_DIR_SRC = path.resolve(CORE_DIR, '..', 'playwright-test');
|
const TEST_DIR_SRC = path.resolve(CORE_DIR, '..', 'playwright-test');
|
||||||
const TEST_DIR_LIB = 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');
|
||||||
@ -78,7 +76,7 @@ export function captureStackTrace(rawStack?: string): ParsedStackTrace {
|
|||||||
type ParsedFrame = {
|
type ParsedFrame = {
|
||||||
frame: StackFrame;
|
frame: StackFrame;
|
||||||
frameText: string;
|
frameText: string;
|
||||||
inClient: boolean;
|
inCore: boolean;
|
||||||
};
|
};
|
||||||
let parsedFrames = stack.split('\n').map(line => {
|
let parsedFrames = stack.split('\n').map(line => {
|
||||||
const frame = stackUtils.parseLine(line);
|
const frame = stackUtils.parseLine(line);
|
||||||
@ -94,7 +92,7 @@ export function captureStackTrace(rawStack?: string): ParsedStackTrace {
|
|||||||
fileName = path.resolve(process.cwd(), frame.file);
|
fileName = path.resolve(process.cwd(), frame.file);
|
||||||
if (isTesting && fileName.includes(COVERAGE_PATH))
|
if (isTesting && fileName.includes(COVERAGE_PATH))
|
||||||
return null;
|
return null;
|
||||||
const inClient = fileName.startsWith(CLIENT_LIB) || fileName.startsWith(CLIENT_SRC) || fileName.startsWith(UTIL_LIB) || fileName.startsWith(UTIL_SRC);
|
const inCore = fileName.startsWith(CORE_LIB) || fileName.startsWith(CORE_SRC);
|
||||||
const parsed: ParsedFrame = {
|
const parsed: ParsedFrame = {
|
||||||
frame: {
|
frame: {
|
||||||
file: fileName,
|
file: fileName,
|
||||||
@ -103,7 +101,7 @@ export function captureStackTrace(rawStack?: string): ParsedStackTrace {
|
|||||||
function: frame.function,
|
function: frame.function,
|
||||||
},
|
},
|
||||||
frameText: line,
|
frameText: line,
|
||||||
inClient
|
inCore
|
||||||
};
|
};
|
||||||
return parsed;
|
return parsed;
|
||||||
}).filter(Boolean) as ParsedFrame[];
|
}).filter(Boolean) as ParsedFrame[];
|
||||||
@ -126,7 +124,7 @@ export function captureStackTrace(rawStack?: string): ParsedStackTrace {
|
|||||||
// Deepest transition between non-client code calling into client code
|
// Deepest transition between non-client code calling into client code
|
||||||
// is the api entry.
|
// is the api entry.
|
||||||
for (let i = 0; i < parsedFrames.length - 1; i++) {
|
for (let i = 0; i < parsedFrames.length - 1; i++) {
|
||||||
if (parsedFrames[i].inClient && !parsedFrames[i + 1].inClient) {
|
if (parsedFrames[i].inCore && !parsedFrames[i + 1].inCore) {
|
||||||
const frame = parsedFrames[i].frame;
|
const frame = parsedFrames[i].frame;
|
||||||
apiName = normalizeAPIName(frame.function);
|
apiName = normalizeAPIName(frame.function);
|
||||||
parsedFrames = parsedFrames.slice(i + 1);
|
parsedFrames = parsedFrames.slice(i + 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user