diff --git a/packages/playwright-core/ThirdPartyNotices.txt b/packages/playwright-core/ThirdPartyNotices.txt index 420d698fa512a..f9d2225d75cc4 100644 --- a/packages/playwright-core/ThirdPartyNotices.txt +++ b/packages/playwright-core/ThirdPartyNotices.txt @@ -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.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 \ No newline at end of file diff --git a/packages/playwright-core/bundles/utils/package-lock.json b/packages/playwright-core/bundles/utils/package-lock.json index 49e99ef5c389c..a70731aa0e1bb 100644 --- a/packages/playwright-core/bundles/utils/package-lock.json +++ b/packages/playwright-core/bundles/utils/package-lock.json @@ -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", diff --git a/packages/playwright-core/bundles/utils/package.json b/packages/playwright-core/bundles/utils/package.json index e7f09cf3a01d9..76f6a4986affe 100644 --- a/packages/playwright-core/bundles/utils/package.json +++ b/packages/playwright-core/bundles/utils/package.json @@ -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", diff --git a/packages/playwright-core/bundles/utils/src/utilsBundleImpl.ts b/packages/playwright-core/bundles/utils/src/utilsBundleImpl.ts index 409372e89448e..284ca5e7ad19f 100644 --- a/packages/playwright-core/bundles/utils/src/utilsBundleImpl.ts +++ b/packages/playwright-core/bundles/utils/src/utilsBundleImpl.ts @@ -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; diff --git a/packages/playwright-core/src/browserServerImpl.ts b/packages/playwright-core/src/browserServerImpl.ts index e8d66bc4c4827..77fb9a984443a 100644 --- a/packages/playwright-core/src/browserServerImpl.ts +++ b/packages/playwright-core/src/browserServerImpl.ts @@ -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'; diff --git a/packages/playwright-core/src/client/browserContext.ts b/packages/playwright-core/src/client/browserContext.ts index 7c0210ceaf5bd..32cac6ba7fd04 100644 --- a/packages/playwright-core/src/client/browserContext.ts +++ b/packages/playwright-core/src/client/browserContext.ts @@ -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'; diff --git a/packages/playwright-core/src/client/channelOwner.ts b/packages/playwright-core/src/client/channelOwner.ts index 70a5c51777d4b..5c5afcdc2defe 100644 --- a/packages/playwright-core/src/client/channelOwner.ts +++ b/packages/playwright-core/src/client/channelOwner.ts @@ -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 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`; diff --git a/packages/playwright-core/src/utils/stackTrace.ts b/packages/playwright-core/src/utils/isomorphic/stackTrace.ts similarity index 84% rename from packages/playwright-core/src/utils/stackTrace.ts rename to packages/playwright-core/src/utils/isomorphic/stackTrace.ts index d3331698d16ee..7ce3f719a4b3f 100644 --- a/packages/playwright-core/src/utils/stackTrace.ts +++ b/packages/playwright-core/src/utils/isomorphic/stackTrace.ts @@ -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: E, newMessage: string): return e; } -const CORE_DIR = path.resolve(__dirname, '..', '..'); +let coreDir: string | undefined; + +const playwrightStackPrefixes: string[] = []; +export const addInternalStackPrefix = (prefix: string) => playwrightStackPrefixes.push(prefix); -const internalStackPrefixes = [ - CORE_DIR, -]; -export const addInternalStackPrefix = (prefix: string) => internalStackPrefixes.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 { diff --git a/packages/playwright-core/src/utils/stackUtils.ts b/packages/playwright-core/src/utils/isomorphic/stackUtils.ts similarity index 88% rename from packages/playwright-core/src/utils/stackUtils.ts rename to packages/playwright-core/src/utils/isomorphic/stackUtils.ts index 024b6fe8d0b04..20be8081afc9d 100644 --- a/packages/playwright-core/src/utils/stackUtils.ts +++ b/packages/playwright-core/src/utils/isomorphic/stackUtils.ts @@ -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); +} diff --git a/packages/playwright-core/src/utils/platform.ts b/packages/playwright-core/src/utils/platform.ts index 60f2cdbd3a26c..5abf38e8c0633 100644 --- a/packages/playwright-core/src/utils/platform.ts +++ b/packages/playwright-core/src/utils/platform.ts @@ -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), }; diff --git a/packages/playwright-core/src/utilsBundle.ts b/packages/playwright-core/src/utilsBundle.ts index 41cccd1f57263..a72f18c30fec3 100644 --- a/packages/playwright-core/src/utilsBundle.ts +++ b/packages/playwright-core/src/utilsBundle.ts @@ -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; diff --git a/packages/playwright/src/matchers/matcherHint.ts b/packages/playwright/src/matchers/matcherHint.ts index 1dfa1ceb4aa89..316ecad6850ea 100644 --- a/packages/playwright/src/matchers/matcherHint.ts +++ b/packages/playwright/src/matchers/matcherHint.ts @@ -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'; diff --git a/packages/playwright/src/matchers/matchers.ts b/packages/playwright/src/matchers/matchers.ts index 2890feaac63ac..d37e3285f455e 100644 --- a/packages/playwright/src/matchers/matchers.ts +++ b/packages/playwright/src/matchers/matchers.ts @@ -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'; diff --git a/packages/playwright/src/matchers/toHaveURL.ts b/packages/playwright/src/matchers/toHaveURL.ts index c56441fee52fc..efc0ebd5f2fce 100644 --- a/packages/playwright/src/matchers/toHaveURL.ts +++ b/packages/playwright/src/matchers/toHaveURL.ts @@ -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'; diff --git a/packages/playwright/src/matchers/toMatchSnapshot.ts b/packages/playwright/src/matchers/toMatchSnapshot.ts index 220c9488871b1..dd54e61aeb874 100644 --- a/packages/playwright/src/matchers/toMatchSnapshot.ts +++ b/packages/playwright/src/matchers/toMatchSnapshot.ts @@ -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 { diff --git a/packages/playwright/src/matchers/toMatchText.ts b/packages/playwright/src/matchers/toMatchText.ts index 961937eb5b5db..142013f1b58af 100644 --- a/packages/playwright/src/matchers/toMatchText.ts +++ b/packages/playwright/src/matchers/toMatchText.ts @@ -15,7 +15,7 @@ */ -import { colors } from 'playwright-core/lib/utilsBundle'; +import { colors } from 'playwright-core/lib/utils'; import { callLogText, expectTypes } from '../util'; import { diff --git a/packages/playwright/src/plugins/webServerPlugin.ts b/packages/playwright/src/plugins/webServerPlugin.ts index 62583c303e112..4bb1bef0db5a7 100644 --- a/packages/playwright/src/plugins/webServerPlugin.ts +++ b/packages/playwright/src/plugins/webServerPlugin.ts @@ -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'; diff --git a/packages/playwright/src/reporters/base.ts b/packages/playwright/src/reporters/base.ts index 156f9755dbe84..8ba5b23af1376 100644 --- a/packages/playwright/src/reporters/base.ts +++ b/packages/playwright/src/reporters/base.ts @@ -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)) diff --git a/packages/playwright/src/reporters/github.ts b/packages/playwright/src/reporters/github.ts index e3677dd3ff482..7c65c00b3ce81 100644 --- a/packages/playwright/src/reporters/github.ts +++ b/packages/playwright/src/reporters/github.ts @@ -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'; diff --git a/packages/playwright/src/reporters/html.ts b/packages/playwright/src/reporters/html.ts index 3390a717468f8..a86a758d487c1 100644 --- a/packages/playwright/src/reporters/html.ts +++ b/packages/playwright/src/reporters/html.ts @@ -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'; diff --git a/packages/playwright/src/runner/dispatcher.ts b/packages/playwright/src/runner/dispatcher.ts index 084deba11d092..cf0c7144c0238 100644 --- a/packages/playwright/src/runner/dispatcher.ts +++ b/packages/playwright/src/runner/dispatcher.ts @@ -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'; diff --git a/packages/playwright/src/runner/rebase.ts b/packages/playwright/src/runner/rebase.ts index c2d9f96d18718..ef7d49f013ac2 100644 --- a/packages/playwright/src/runner/rebase.ts +++ b/packages/playwright/src/runner/rebase.ts @@ -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'; diff --git a/packages/playwright/src/runner/taskRunner.ts b/packages/playwright/src/runner/taskRunner.ts index 12185aa951d5e..ea0561faaab20 100644 --- a/packages/playwright/src/runner/taskRunner.ts +++ b/packages/playwright/src/runner/taskRunner.ts @@ -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'; diff --git a/packages/playwright/src/runner/watchMode.ts b/packages/playwright/src/runner/watchMode.ts index c9768c47ba23f..ad819853fce11 100644 --- a/packages/playwright/src/runner/watchMode.ts +++ b/packages/playwright/src/runner/watchMode.ts @@ -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'; diff --git a/packages/playwright/src/util.ts b/packages/playwright/src/util.ts index 803aa73f6bc21..a890535feea62 100644 --- a/packages/playwright/src/util.ts +++ b/packages/playwright/src/util.ts @@ -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)) diff --git a/packages/playwright/src/worker/timeoutManager.ts b/packages/playwright/src/worker/timeoutManager.ts index 7018dafcc9ea0..65e97c9f36a05 100644 --- a/packages/playwright/src/worker/timeoutManager.ts +++ b/packages/playwright/src/worker/timeoutManager.ts @@ -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'; diff --git a/packages/playwright/src/worker/workerMain.ts b/packages/playwright/src/worker/workerMain.ts index 30b59c36e73af..e09579d0e0e22 100644 --- a/packages/playwright/src/worker/workerMain.ts +++ b/packages/playwright/src/worker/workerMain.ts @@ -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';