chore: remove stackTrace => path dependency (#34763)

This commit is contained in:
Pavel Feldman 2025-02-12 18:03:23 -08:00 committed by GitHub
parent c31ce783b7
commit e697b1a663
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
42 changed files with 201 additions and 148 deletions

View File

@ -11,7 +11,6 @@ This project incorporates components from the projects listed below. The origina
- brace-expansion@1.1.11 (https://github.com/juliangruber/brace-expansion)
- buffer-crc32@0.2.13 (https://github.com/brianloveswords/buffer-crc32)
- codemirror@5.65.18 (https://github.com/codemirror/CodeMirror)
- colors@1.4.0 (https://github.com/Marak/colors.js)
- commander@8.3.0 (https://github.com/tj/commander.js)
- concat-map@0.0.1 (https://github.com/substack/node-concat-map)
- debug@4.3.4 (https://github.com/debug-js/debug)
@ -355,36 +354,6 @@ THE SOFTWARE.
=========================================
END OF codemirror@5.65.18 AND INFORMATION
%% colors@1.4.0 NOTICES AND INFORMATION BEGIN HERE
=========================================
MIT License
Original Library
- Copyright (c) Marak Squires
Additional Functionality
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
=========================================
END OF colors@1.4.0 AND INFORMATION
%% commander@8.3.0 NOTICES AND INFORMATION BEGIN HERE
=========================================
(The MIT License)
@ -1555,6 +1524,6 @@ END OF yazl@2.5.1 AND INFORMATION
SUMMARY BEGIN HERE
=========================================
Total Packages: 46
Total Packages: 45
=========================================
END OF SUMMARY

View File

@ -8,7 +8,6 @@
"name": "utils-bundle",
"version": "0.0.1",
"dependencies": {
"colors": "1.4.0",
"commander": "8.3.0",
"debug": "^4.3.4",
"diff": "^7.0.0",
@ -163,14 +162,6 @@
"concat-map": "0.0.1"
}
},
"node_modules/colors": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz",
"integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==",
"engines": {
"node": ">=0.1.90"
}
},
"node_modules/commander": {
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz",

View File

@ -9,7 +9,6 @@
"generate-license": "node ../../../../utils/generate_third_party_notice.js"
},
"dependencies": {
"colors": "1.4.0",
"commander": "8.3.0",
"debug": "^4.3.4",
"diff": "^7.0.0",

View File

@ -16,9 +16,6 @@
/* eslint-disable import/order */
import colorsLibrary from 'colors/safe';
export const colors = colorsLibrary;
import debugLibrary from 'debug';
export const debug = debugLibrary;

View File

@ -21,7 +21,7 @@ import { helper } from './server/helper';
import { serverSideCallMetadata } from './server/instrumentation';
import { createPlaywright } from './server/playwright';
import { createGuid } from './server/utils/crypto';
import { rewriteErrorMessage } from './utils/stackTrace';
import { rewriteErrorMessage } from './utils/isomorphic/stackTrace';
import { ws } from './utilsBundle';
import type { BrowserServer, BrowserServerLauncher } from './client/browserType';

View File

@ -39,7 +39,7 @@ import { mkdirIfNeeded } from '../utils/fileUtils';
import { headersObjectToArray } from '../utils/isomorphic/headers';
import { urlMatchesEqual } from '../utils/isomorphic/urlMatch';
import { isRegExp, isString } from '../utils/isomorphic/rtti';
import { rewriteErrorMessage } from '../utils/stackTrace';
import { rewriteErrorMessage } from '../utils/isomorphic/stackTrace';
import type { BrowserType } from './browserType';
import type { BrowserContextOptions, Headers, LaunchOptions, StorageState, WaitForEventOptions } from './types';

View File

@ -18,7 +18,7 @@ import { EventEmitter } from './eventEmitter';
import { ValidationError, maybeFindValidator } from '../protocol/validator';
import { isUnderTest } from '../utils/debug';
import { debugLogger } from '../utils/debugLogger';
import { captureLibraryStackTrace, stringifyStackFrames } from '../utils/stackTrace';
import { captureLibraryStackTrace, stringifyStackFrames } from '../utils/isomorphic/stackTrace';
import { zones } from '../utils/zones';
import type { ClientInstrumentation } from './clientInstrumentation';
@ -183,7 +183,7 @@ export abstract class ChannelOwner<T extends channels.Channel = channels.Channel
if (isInternal === undefined)
isInternal = this._isInternalType;
const stackTrace = captureLibraryStackTrace();
const stackTrace = captureLibraryStackTrace(this._platform.pathSeparator);
const apiZone: ApiZone = { apiName: stackTrace.apiName, frames: stackTrace.frames, isInternal, reported: false, userData: undefined, stepId: undefined };
try {

View File

@ -43,7 +43,7 @@ import { Worker } from './worker';
import { WritableStream } from './writableStream';
import { ValidationError, findValidator } from '../protocol/validator';
import { debugLogger } from '../utils/debugLogger';
import { formatCallLog, rewriteErrorMessage } from '../utils/stackTrace';
import { formatCallLog, rewriteErrorMessage } from '../utils/isomorphic/stackTrace';
import { zones } from '../utils/zones';
import type { ClientInstrumentation } from './clientInstrumentation';

View File

@ -29,7 +29,7 @@ import { urlMatches } from '../utils/isomorphic/urlMatch';
import { LongStandingScope, ManualPromise } from '../utils/isomorphic/manualPromise';
import { MultiMap } from '../utils/isomorphic/multimap';
import { isRegExp, isString } from '../utils/isomorphic/rtti';
import { rewriteErrorMessage } from '../utils/stackTrace';
import { rewriteErrorMessage } from '../utils/isomorphic/stackTrace';
import { zones } from '../utils/zones';
import { mime } from '../utilsBundle';

View File

@ -15,7 +15,7 @@
*/
import { TimeoutError } from './errors';
import { rewriteErrorMessage } from '../utils/stackTrace';
import { rewriteErrorMessage } from '../utils/isomorphic/stackTrace';
import { zones } from '../utils/zones';
import type { ChannelOwner } from './channelOwner';

View File

@ -14,10 +14,13 @@
* limitations under the License.
*/
import path from 'path';
import { AndroidServerLauncherImpl } from './androidServerImpl';
import { BrowserServerLauncherImpl } from './browserServerImpl';
import { Connection } from './client/connection';
import { DispatcherConnection, PlaywrightDispatcher, RootDispatcher, createPlaywright } from './server';
import { setLibraryStackPrefix } from './utils/isomorphic/stackTrace';
import type { Playwright as PlaywrightAPI } from './client/playwright';
import type { Language } from './utils';
@ -25,6 +28,7 @@ import type { Platform } from './utils/platform';
export function createInProcessPlaywright(platform: Platform): PlaywrightAPI {
const playwright = createPlaywright({ sdkLanguage: (process.env.PW_LANG_NAME as Language | undefined) || 'javascript' });
setLibraryStackPrefix(path.join(__dirname, '..'));
const clientConnection = new Connection(undefined, platform, undefined, []);
clientConnection.useRawBuffers();

View File

@ -16,7 +16,7 @@
*/
import { getExceptionMessage, releaseObject } from './crProtocolHelper';
import { rewriteErrorMessage } from '../../utils/stackTrace';
import { rewriteErrorMessage } from '../../utils/isomorphic/stackTrace';
import { parseEvaluationResultValue } from '../isomorphic/utilityScriptSerializers';
import * as js from '../javascript';
import { isSessionClosedError } from '../protocolError';

View File

@ -20,7 +20,7 @@ import * as path from 'path';
import { assert } from '../../utils/debug';
import { createGuid } from '../utils/crypto';
import { eventsHelper } from '../utils/eventsHelper';
import { rewriteErrorMessage } from '../../utils/stackTrace';
import { rewriteErrorMessage } from '../../utils/isomorphic/stackTrace';
import * as dialog from '../dialog';
import * as dom from '../dom';
import * as frames from '../frames';

View File

@ -17,7 +17,7 @@
import * as fs from 'fs';
import { splitErrorMessage } from '../../utils/stackTrace';
import { splitErrorMessage } from '../../utils/isomorphic/stackTrace';
import { mkdirIfNeeded } from '../utils/fileUtils';
import type { CRSession } from './crConnection';

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { rewriteErrorMessage } from '../../utils/stackTrace';
import { rewriteErrorMessage } from '../../utils/isomorphic/stackTrace';
import { parseEvaluationResultValue } from '../isomorphic/utilityScriptSerializers';
import * as js from '../javascript';
import { isSessionClosedError } from '../protocolError';

View File

@ -26,7 +26,7 @@ import { FFExecutionContext } from './ffExecutionContext';
import { RawKeyboardImpl, RawMouseImpl, RawTouchscreenImpl } from './ffInput';
import { FFNetworkManager } from './ffNetworkManager';
import { debugLogger } from '../../utils/debugLogger';
import { splitErrorMessage } from '../../utils/stackTrace';
import { splitErrorMessage } from '../../utils/isomorphic/stackTrace';
import { BrowserContext } from '../browserContext';
import { TargetClosedError } from '../errors';

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
import { rewriteErrorMessage } from '../utils/stackTrace';
import { rewriteErrorMessage } from '../utils/isomorphic/stackTrace';
export class ProtocolError extends Error {
type: 'error' | 'closed' | 'crashed';

View File

@ -23,7 +23,8 @@ import * as path from 'path';
import { debugLogger } from '../../utils/debugLogger';
import { ManualPromise } from '../../utils/isomorphic/manualPromise';
import { getUserAgent } from '../../utils/userAgent';
import { colors, progress as ProgressBar } from '../../utilsBundle';
import { progress as ProgressBar } from '../../utilsBundle';
import { colors } from '../../utils/isomorphic/colors';
import { existsAsync } from '../utils/fileUtils';
import { browserDirectoryToMarkerFilePath } from '.';

View File

@ -18,7 +18,8 @@
import { compare } from './image_tools/compare';
// @ts-ignore
import pixelmatch from '../../third_party/pixelmatch';
import { colors, jpegjs } from '../../utilsBundle';
import { jpegjs } from '../../utilsBundle';
import { colors } from '../../utils/isomorphic/colors';
import { diff } from '../../utilsBundle';
import { PNG } from '../../utilsBundle';

View File

@ -22,7 +22,7 @@ import { headersArrayToObject } from '../../utils/isomorphic/headers';
import { createGuid } from '../utils/crypto';
import { eventsHelper } from '../utils/eventsHelper';
import { hostPlatform } from '../../utils/hostPlatform';
import { splitErrorMessage } from '../../utils/stackTrace';
import { splitErrorMessage } from '../../utils/isomorphic/stackTrace';
import { PNG, jpegjs } from '../../utilsBundle';
import { BrowserContext } from '../browserContext';
import * as dialog from '../dialog';

View File

@ -14,6 +14,7 @@
* limitations under the License.
*/
export * from './utils/isomorphic/colors';
export * from './utils/isomorphic/locatorGenerators';
export * from './utils/isomorphic/manualPromise';
export * from './utils/isomorphic/mimeType';
@ -31,7 +32,7 @@ export * from './utils/hostPlatform';
export * from './utils/isomorphic/headers';
export * from './utils/isomorphic/semaphore';
export * from './utils/platform';
export * from './utils/stackTrace';
export * from './utils/isomorphic/stackTrace';
export * from './utils/task';
export * from './utils/userAgent';
export * from './utils/zipFile';

View File

@ -0,0 +1,117 @@
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const colors = {
enabled: true,
reset: (text: string) => applyStyle(0, 0, text),
bold: (text: string) => applyStyle(1, 22, text),
dim: (text: string) => applyStyle(2, 22, text),
italic: (text: string) => applyStyle(3, 23, text),
underline: (text: string) => applyStyle(4, 24, text),
inverse: (text: string) => applyStyle(7, 27, text),
hidden: (text: string) => applyStyle(8, 28, text),
strikethrough: (text: string) => applyStyle(9, 29, text),
black: (text: string) => applyStyle(30, 39, text),
red: (text: string) => applyStyle(31, 39, text),
green: (text: string) => applyStyle(32, 39, text),
yellow: (text: string) => applyStyle(33, 39, text),
blue: (text: string) => applyStyle(34, 39, text),
magenta: (text: string) => applyStyle(35, 39, text),
cyan: (text: string) => applyStyle(36, 39, text),
white: (text: string) => applyStyle(37, 39, text),
gray: (text: string) => applyStyle(90, 39, text),
grey: (text: string) => applyStyle(90, 39, text),
brightRed: (text: string) => applyStyle(91, 39, text),
brightGreen: (text: string) => applyStyle(92, 39, text),
brightYellow: (text: string) => applyStyle(93, 39, text),
brightBlue: (text: string) => applyStyle(94, 39, text),
brightMagenta: (text: string) => applyStyle(95, 39, text),
brightCyan: (text: string) => applyStyle(96, 39, text),
brightWhite: (text: string) => applyStyle(97, 39, text),
bgBlack: (text: string) => applyStyle(40, 49, text),
bgRed: (text: string) => applyStyle(41, 49, text),
bgGreen: (text: string) => applyStyle(42, 49, text),
bgYellow: (text: string) => applyStyle(43, 49, text),
bgBlue: (text: string) => applyStyle(44, 49, text),
bgMagenta: (text: string) => applyStyle(45, 49, text),
bgCyan: (text: string) => applyStyle(46, 49, text),
bgWhite: (text: string) => applyStyle(47, 49, text),
bgGray: (text: string) => applyStyle(100, 49, text),
bgGrey: (text: string) => applyStyle(100, 49, text),
bgBrightRed: (text: string) => applyStyle(101, 49, text),
bgBrightGreen: (text: string) => applyStyle(102, 49, text),
bgBrightYellow: (text: string) => applyStyle(103, 49, text),
bgBrightBlue: (text: string) => applyStyle(104, 49, text),
bgBrightMagenta: (text: string) => applyStyle(105, 49, text),
bgBrightCyan: (text: string) => applyStyle(106, 49, text),
bgBrightWhite: (text: string) => applyStyle(107, 49, text),
};
type Colors = typeof colors;
export const noColors: Colors = {
enabled: false,
reset: t => t,
bold: t => t,
dim: t => t,
italic: t => t,
underline: t => t,
inverse: t => t,
hidden: t => t,
strikethrough: t => t,
black: t => t,
red: t => t,
green: t => t,
yellow: t => t,
blue: t => t,
magenta: t => t,
cyan: t => t,
white: t => t,
gray: t => t,
grey: t => t,
brightRed: t => t,
brightGreen: t => t,
brightYellow: t => t,
brightBlue: t => t,
brightMagenta: t => t,
brightCyan: t => t,
brightWhite: t => t,
bgBlack: t => t,
bgRed: t => t,
bgGreen: t => t,
bgYellow: t => t,
bgBlue: t => t,
bgMagenta: t => t,
bgCyan: t => t,
bgWhite: t => t,
bgGray: t => t,
bgGrey: t => t,
bgBrightRed: t => t,
bgBrightGreen: t => t,
bgBrightYellow: t => t,
bgBrightBlue: t => t,
bgBrightMagenta: t => t,
bgBrightCyan: t => t,
bgBrightWhite: t => t
};
const applyStyle = (open: number, close: number, text: string) => `\u001b[${open}m${text}\u001b[${close}m`;

View File

@ -14,16 +14,14 @@
* limitations under the License.
*/
import * as path from 'path';
import { colors } from '../utilsBundle';
import { findRepeatedSubsequences } from './isomorphic/sequence';
import { colors } from './colors';
import { findRepeatedSubsequences } from './sequence';
import { parseStackFrame } from './stackUtils';
import type { StackFrame } from '@protocol/channels';
export function parseStackTraceLine(line: string): StackFrame | null {
const frame = parseStackFrame(line);
export function parseStackTraceLine(line: string, pathSeparator: string): StackFrame | null {
const frame = parseStackFrame(line, pathSeparator);
if (!frame)
return null;
if (!process.env.PWDEBUGIMPL && (frame.file?.startsWith('internal') || frame.file?.startsWith('node:')))
@ -47,12 +45,15 @@ export function rewriteErrorMessage<E extends Error>(e: E, newMessage: string):
return e;
}
const CORE_DIR = path.resolve(__dirname, '..', '..');
let coreDir: string | undefined;
const internalStackPrefixes = [
CORE_DIR,
];
export const addInternalStackPrefix = (prefix: string) => internalStackPrefixes.push(prefix);
const playwrightStackPrefixes: string[] = [];
export const addInternalStackPrefix = (prefix: string) => playwrightStackPrefixes.push(prefix);
export const setLibraryStackPrefix = (prefix: string) => {
coreDir = prefix;
playwrightStackPrefixes.push(prefix);
};
export type RawStack = string[];
@ -65,7 +66,7 @@ export function captureRawStack(): RawStack {
return stack.split('\n');
}
export function captureLibraryStackTrace(): { frames: StackFrame[], apiName: string } {
export function captureLibraryStackTrace(pathSeparator: string): { frames: StackFrame[], apiName: string } {
const stack = captureRawStack();
type ParsedFrame = {
@ -74,10 +75,10 @@ export function captureLibraryStackTrace(): { frames: StackFrame[], apiName: str
isPlaywrightLibrary: boolean;
};
let parsedFrames = stack.map(line => {
const frame = parseStackTraceLine(line);
const frame = parseStackTraceLine(line, pathSeparator);
if (!frame || !frame.file)
return null;
const isPlaywrightLibrary = frame.file.startsWith(CORE_DIR);
const isPlaywrightLibrary = !!coreDir && frame.file.startsWith(coreDir);
const parsed: ParsedFrame = {
frame,
frameText: line,
@ -111,7 +112,7 @@ export function captureLibraryStackTrace(): { frames: StackFrame[], apiName: str
parsedFrames = parsedFrames.filter(f => {
if (process.env.PWDEBUGIMPL)
return true;
if (internalStackPrefixes.some(prefix => f.frame.file.startsWith(prefix)))
if (playwrightStackPrefixes.some(prefix => f.frame.file.startsWith(prefix)))
return false;
return true;
});
@ -133,11 +134,6 @@ export function stringifyStackFrames(frames: StackFrame[]): string[] {
return stackLines;
}
export function captureLibraryStackText() {
const parsed = captureLibraryStackTrace();
return stringifyStackFrames(parsed.frames).join('\n');
}
export function splitErrorMessage(message: string): { name: string, message: string } {
const separationIdx = message.indexOf(':');
return {

View File

@ -19,8 +19,6 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import * as url from 'url';
type StackData = {
line?: number;
column?: number;
@ -35,7 +33,7 @@ type StackData = {
evalFile?: string | undefined;
};
export function parseStackFrame(line: string): StackData | null {
export function parseStackFrame(line: string, pathSeparator: string): StackData | null {
const match = line && line.match(re);
if (!match)
return null;
@ -92,7 +90,7 @@ export function parseStackFrame(line: string): StackData | null {
}
}
setFile(res, file);
setFile(res, file, pathSeparator);
if (ctor)
res.isConstructor = true;
@ -113,10 +111,10 @@ export function parseStackFrame(line: string): StackData | null {
return res;
}
function setFile(result: StackData, filename: string) {
function setFile(result: StackData, filename: string, pathSeparator: string) {
if (filename) {
if (filename.startsWith('file://'))
filename = url.fileURLToPath(filename);
filename = fileURLToPath(filename, pathSeparator);
result.file = filename;
}
}
@ -147,3 +145,14 @@ const re = new RegExp('^' +
);
const methodRe = /^(.*?) \[as (.*?)\]$/;
function fileURLToPath(fileUrl: string, pathSeparator: string): string {
if (!fileUrl.startsWith('file://'))
return fileUrl;
let path = decodeURIComponent(fileUrl.slice(7));
if (path.startsWith('/') && /^[a-zA-Z]:/.test(path.slice(1)))
path = path.slice(1);
return path.replace(/\//g, pathSeparator);
}

View File

@ -25,6 +25,7 @@ export type Platform = {
fs: () => typeof fs;
inspectCustom: symbol | undefined;
path: () => typeof path;
pathSeparator: string;
ws?: (url: string) => WebSocket;
};
@ -42,6 +43,8 @@ export const nodePlatform: Platform = {
inspectCustom: util.inspect.custom,
path: () => path,
pathSeparator: path.sep
};
export const webPlatform: Platform = {
@ -65,5 +68,7 @@ export const webPlatform: Platform = {
throw new Error('Path module is not available');
},
pathSeparator: '/',
ws: (url: string) => new WebSocket(url),
};

View File

@ -14,7 +14,6 @@
* limitations under the License.
*/
export const colors: typeof import('../bundles/utils/node_modules/colors/safe') = require('./utilsBundleImpl').colors;
export const debug: typeof import('../bundles/utils/node_modules/@types/debug') = require('./utilsBundleImpl').debug;
export const diff: typeof import('../bundles/utils/node_modules/@types/diff') = require('./utilsBundleImpl').diff;
export const dotenv: typeof import('../bundles/utils/node_modules/dotenv') = require('./utilsBundleImpl').dotenv;

View File

@ -15,7 +15,7 @@
*/
import { stringifyStackFrames } from 'playwright-core/lib/utils';
import { colors } from 'playwright-core/lib/utilsBundle';
import { colors } from 'playwright-core/lib/utils';
import type { ExpectMatcherState } from '../../types/test';
import type { StackFrame } from '@protocol/channels';

View File

@ -15,7 +15,7 @@
*/
import { isRegExp, isString, isTextualMimeType, pollAgainstDeadline, serializeExpectedTextValues } from 'playwright-core/lib/utils';
import { colors } from 'playwright-core/lib/utilsBundle';
import { colors } from 'playwright-core/lib/utils';
import { callLogText, expectTypes } from '../util';
import { toBeTruthy } from './toBeTruthy';

View File

@ -15,7 +15,7 @@
*/
import { constructURLBasedOnBaseURL, urlMatches } from 'playwright-core/lib/utils';
import { colors } from 'playwright-core/lib/utilsBundle';
import { colors } from 'playwright-core/lib/utils';
import { printReceivedStringContainExpectedResult, printReceivedStringContainExpectedSubstring } from './expect';
import { matcherHint } from './matcherHint';

View File

@ -18,7 +18,7 @@ import * as fs from 'fs';
import * as path from 'path';
import { compareBuffersOrStrings, getComparator, isString, sanitizeForFilePath } from 'playwright-core/lib/utils';
import { colors } from 'playwright-core/lib/utilsBundle';
import { colors } from 'playwright-core/lib/utils';
import { mime } from 'playwright-core/lib/utilsBundle';
import {

View File

@ -15,7 +15,7 @@
*/
import { colors } from 'playwright-core/lib/utilsBundle';
import { colors } from 'playwright-core/lib/utils';
import { callLogText, expectTypes } from '../util';
import {

View File

@ -17,7 +17,8 @@ import * as net from 'net';
import * as path from 'path';
import { launchProcess, isURLAvailable, monotonicTime, raceAgainstDeadline } from 'playwright-core/lib/utils';
import { colors, debug } from 'playwright-core/lib/utilsBundle';
import { colors } from 'playwright-core/lib/utils';
import { debug } from 'playwright-core/lib/utilsBundle';
import type { TestRunnerPlugin } from '.';
import type { FullConfig } from '../../types/testReporter';

View File

@ -18,7 +18,8 @@ import * as path from 'path';
import { getPackageManagerExecCommand } from 'playwright-core/lib/utils';
import { parseStackTraceLine } from 'playwright-core/lib/utils';
import { colors as realColors, ms as milliseconds } from 'playwright-core/lib/utilsBundle';
import { ms as milliseconds } from 'playwright-core/lib/utilsBundle';
import { colors as realColors, noColors } from 'playwright-core/lib/utils';
import { resolveReporterOutputPath } from '../util';
import { getEastAsianWidth } from '../utilsBundle';
@ -53,48 +54,6 @@ export type Screen = {
ttyWidth: number;
};
export const noColors: Colors = {
bold: (t: string) => t,
cyan: (t: string) => t,
dim: (t: string) => t,
gray: (t: string) => t,
green: (t: string) => t,
red: (t: string) => t,
yellow: (t: string) => t,
black: (t: string) => t,
blue: (t: string) => t,
magenta: (t: string) => t,
white: (t: string) => t,
grey: (t: string) => t,
bgBlack: (t: string) => t,
bgRed: (t: string) => t,
bgGreen: (t: string) => t,
bgYellow: (t: string) => t,
bgBlue: (t: string) => t,
bgMagenta: (t: string) => t,
bgCyan: (t: string) => t,
bgWhite: (t: string) => t,
strip: (t: string) => t,
stripColors: (t: string) => t,
reset: (t: string) => t,
italic: (t: string) => t,
underline: (t: string) => t,
inverse: (t: string) => t,
hidden: (t: string) => t,
strikethrough: (t: string) => t,
rainbow: (t: string) => t,
zebra: (t: string) => t,
america: (t: string) => t,
trap: (t: string) => t,
random: (t: string) => t,
zalgo: (t: string) => t,
enabled: false,
enable: () => {},
disable: () => {},
setTheme: () => {},
};
// Output goes to terminal.
export const terminalScreen: Screen = (() => {
let isTTY = !!process.stdout.isTTY;
@ -563,7 +522,7 @@ export function prepareErrorStack(stack: string): {
const stackLines = lines.slice(firstStackLine);
let location: Location | undefined;
for (const line of stackLines) {
const frame = parseStackTraceLine(line);
const frame = parseStackTraceLine(line, path.sep);
if (!frame || !frame.file)
continue;
if (belongsToNodeModules(frame.file))

View File

@ -16,9 +16,10 @@
import * as path from 'path';
import { noColors } from 'playwright-core/lib/utils';
import { ms as milliseconds } from 'playwright-core/lib/utilsBundle';
import { TerminalReporter, formatResultFailure, formatRetry, noColors, stripAnsiEscapes } from './base';
import { TerminalReporter, formatResultFailure, formatRetry, stripAnsiEscapes } from './base';
import type { FullResult, TestCase, TestError } from '../../types/testReporter';

View File

@ -19,7 +19,8 @@ import * as path from 'path';
import { Transform } from 'stream';
import { HttpServer, MultiMap, assert, calculateSha1, getPackageManagerExecCommand, copyFileAndMakeWritable, gracefullyProcessExitDoNotHang, removeFolders, sanitizeForFilePath, toPosixPath } from 'playwright-core/lib/utils';
import { colors, open } from 'playwright-core/lib/utilsBundle';
import { colors } from 'playwright-core/lib/utils';
import { open } from 'playwright-core/lib/utilsBundle';
import { mime } from 'playwright-core/lib/utilsBundle';
import { yazl } from 'playwright-core/lib/zipBundle';

View File

@ -15,7 +15,7 @@
*/
import { ManualPromise, eventsHelper } from 'playwright-core/lib/utils';
import { colors } from 'playwright-core/lib/utilsBundle';
import { colors } from 'playwright-core/lib/utils';
import { addSuggestedRebaseline } from './rebase';
import { WorkerHost } from './workerHost';

View File

@ -19,7 +19,8 @@ import * as path from 'path';
import { MultiMap } from 'playwright-core/lib/utils';
import { colors, diff } from 'playwright-core/lib/utilsBundle';
import { colors } from 'playwright-core/lib/utils';
import { diff } from 'playwright-core/lib/utilsBundle';
import { filterProjects } from './projectUtils';
import { babelParse, traverse, types } from '../transform/babelBundle';

View File

@ -15,7 +15,8 @@
*/
import { ManualPromise, monotonicTime } from 'playwright-core/lib/utils';
import { colors, debug } from 'playwright-core/lib/utilsBundle';
import { colors } from 'playwright-core/lib/utils';
import { debug } from 'playwright-core/lib/utilsBundle';
import { SigIntWatcher } from './sigIntWatcher';

View File

@ -20,7 +20,7 @@ import { EventEmitter } from 'stream';
import { PlaywrightServer } from 'playwright-core/lib/remote/playwrightServer';
import { ManualPromise, createGuid, eventsHelper, getPackageManagerExecCommand } from 'playwright-core/lib/utils';
import { colors } from 'playwright-core/lib/utilsBundle';
import { colors } from 'playwright-core/lib/utils';
import { separator, terminalScreen } from '../reporters/base';
import { enquirer } from '../utilsBundle';

View File

@ -55,7 +55,7 @@ export function filterStackFile(file: string) {
export function filteredStackTrace(rawStack: RawStack): StackFrame[] {
const frames: StackFrame[] = [];
for (const line of rawStack) {
const frame = parseStackTraceLine(line);
const frame = parseStackTraceLine(line, path.sep);
if (!frame || !frame.file)
continue;
if (!filterStackFile(frame.file))

View File

@ -15,7 +15,7 @@
*/
import { ManualPromise, monotonicTime } from 'playwright-core/lib/utils';
import { colors } from 'playwright-core/lib/utilsBundle';
import { colors } from 'playwright-core/lib/utils';
import type { Location } from '../../types/testReporter';

View File

@ -15,7 +15,7 @@
*/
import { ManualPromise, gracefullyCloseAll, removeFolders } from 'playwright-core/lib/utils';
import { colors } from 'playwright-core/lib/utilsBundle';
import { colors } from 'playwright-core/lib/utils';
import { deserializeConfig } from '../common/configLoader';
import { setCurrentTestInfo, setIsWorkerProcess } from '../common/globals';