playwright
Advanced tools
Comparing version 1.50.0-alpha-2025-01-06 to 1.50.0-alpha-2025-01-07
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.colors = exports.BaseReporter = void 0; | ||
exports.TerminalReporter = void 0; | ||
exports.fitToWidth = fitToWidth; | ||
@@ -13,5 +13,3 @@ exports.formatError = formatError; | ||
exports.formatRetry = formatRetry; | ||
exports.formatTestHeader = formatTestHeader; | ||
exports.formatTestTitle = formatTestTitle; | ||
exports.kOutputSymbol = exports.isTTY = void 0; | ||
exports.nonTerminalScreen = exports.noColors = exports.kOutputSymbol = exports.internalScreen = void 0; | ||
exports.prepareErrorStack = prepareErrorStack; | ||
@@ -23,3 +21,3 @@ exports.relativeFilePath = relativeFilePath; | ||
exports.stripAnsiEscapes = stripAnsiEscapes; | ||
exports.ttyWidth = void 0; | ||
exports.terminalScreen = void 0; | ||
var _utilsBundle = require("playwright-core/lib/utilsBundle"); | ||
@@ -48,7 +46,45 @@ var _path = _interopRequireDefault(require("path")); | ||
const kOutputSymbol = exports.kOutputSymbol = Symbol('output'); | ||
const { | ||
isTTY, | ||
ttyWidth, | ||
colors | ||
} = (() => { | ||
const noColors = exports.noColors = { | ||
bold: t => t, | ||
cyan: t => t, | ||
dim: t => t, | ||
gray: t => t, | ||
green: t => t, | ||
red: t => t, | ||
yellow: t => t, | ||
black: t => t, | ||
blue: t => t, | ||
magenta: t => t, | ||
white: t => t, | ||
grey: 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, | ||
strip: t => t, | ||
stripColors: t => t, | ||
reset: t => t, | ||
italic: t => t, | ||
underline: t => t, | ||
inverse: t => t, | ||
hidden: t => t, | ||
strikethrough: t => t, | ||
rainbow: t => t, | ||
zebra: t => t, | ||
america: t => t, | ||
trap: t => t, | ||
random: t => t, | ||
zalgo: t => t, | ||
enabled: false, | ||
enable: () => {}, | ||
disable: () => {}, | ||
setTheme: () => {} | ||
}; | ||
// Output goes to terminal. | ||
const terminalScreen = exports.terminalScreen = (() => { | ||
let isTTY = !!process.stdout.isTTY; | ||
@@ -69,13 +105,5 @@ let ttyWidth = process.stdout.columns || 0; | ||
if (process.env.DEBUG_COLORS === '0' || process.env.DEBUG_COLORS === 'false' || process.env.FORCE_COLOR === '0' || process.env.FORCE_COLOR === 'false') useColors = false;else if (process.env.DEBUG_COLORS || process.env.FORCE_COLOR) useColors = true; | ||
const colors = useColors ? _utilsBundle.colors : { | ||
bold: t => t, | ||
cyan: t => t, | ||
dim: t => t, | ||
gray: t => t, | ||
green: t => t, | ||
red: t => t, | ||
yellow: t => t, | ||
enabled: false | ||
}; | ||
const colors = useColors ? _utilsBundle.colors : noColors; | ||
return { | ||
resolveFiles: 'cwd', | ||
isTTY, | ||
@@ -86,7 +114,21 @@ ttyWidth, | ||
})(); | ||
exports.colors = colors; | ||
exports.ttyWidth = ttyWidth; | ||
exports.isTTY = isTTY; | ||
class BaseReporter { | ||
// Output does not go to terminal, but colors are controlled with terminal env vars. | ||
const nonTerminalScreen = exports.nonTerminalScreen = { | ||
colors: terminalScreen.colors, | ||
isTTY: false, | ||
ttyWidth: 0, | ||
resolveFiles: 'rootDir' | ||
}; | ||
// Internal output for post-processing, should always contain real colors. | ||
const internalScreen = exports.internalScreen = { | ||
colors: _utilsBundle.colors, | ||
isTTY: false, | ||
ttyWidth: 0, | ||
resolveFiles: 'rootDir' | ||
}; | ||
class TerminalReporter { | ||
constructor(options = {}) { | ||
this.screen = terminalScreen; | ||
this.config = void 0; | ||
@@ -132,3 +174,3 @@ this.suite = void 0; | ||
const projectName = test.titlePath()[1]; | ||
const relativePath = relativeTestPath(this.config, test); | ||
const relativePath = relativeTestPath(this.screen, this.config, test); | ||
const fileAndProject = (projectName ? `[${projectName}] › ` : '') + relativePath; | ||
@@ -150,7 +192,7 @@ const entry = this.fileDurations.get(fileAndProject) || { | ||
fitToScreen(line, prefix) { | ||
if (!ttyWidth) { | ||
if (!this.screen.ttyWidth) { | ||
// Guard against the case where we cannot determine available width. | ||
return line; | ||
} | ||
return fitToWidth(line, ttyWidth, prefix); | ||
return fitToWidth(line, this.screen.ttyWidth, prefix); | ||
} | ||
@@ -162,3 +204,3 @@ generateStartingMessage() { | ||
if (!this.totalTestCount) return ''; | ||
return '\n' + colors.dim('Running ') + this.totalTestCount + colors.dim(` test${this.totalTestCount !== 1 ? 's' : ''} using `) + jobs + colors.dim(` worker${jobs !== 1 ? 's' : ''}${shardDetails}`); | ||
return '\n' + this.screen.colors.dim('Running ') + this.totalTestCount + this.screen.colors.dim(` test${this.totalTestCount !== 1 ? 's' : ''} using `) + jobs + this.screen.colors.dim(` worker${jobs !== 1 ? 's' : ''}${shardDetails}`); | ||
} | ||
@@ -185,4 +227,4 @@ getSlowTests() { | ||
if (unexpected.length) { | ||
tokens.push(colors.red(` ${unexpected.length} failed`)); | ||
for (const test of unexpected) tokens.push(colors.red(formatTestHeader(this.config, test, { | ||
tokens.push(this.screen.colors.red(` ${unexpected.length} failed`)); | ||
for (const test of unexpected) tokens.push(this.screen.colors.red(this.formatTestHeader(test, { | ||
indent: ' ' | ||
@@ -192,4 +234,4 @@ }))); | ||
if (interrupted.length) { | ||
tokens.push(colors.yellow(` ${interrupted.length} interrupted`)); | ||
for (const test of interrupted) tokens.push(colors.yellow(formatTestHeader(this.config, test, { | ||
tokens.push(this.screen.colors.yellow(` ${interrupted.length} interrupted`)); | ||
for (const test of interrupted) tokens.push(this.screen.colors.yellow(this.formatTestHeader(test, { | ||
indent: ' ' | ||
@@ -199,11 +241,11 @@ }))); | ||
if (flaky.length) { | ||
tokens.push(colors.yellow(` ${flaky.length} flaky`)); | ||
for (const test of flaky) tokens.push(colors.yellow(formatTestHeader(this.config, test, { | ||
tokens.push(this.screen.colors.yellow(` ${flaky.length} flaky`)); | ||
for (const test of flaky) tokens.push(this.screen.colors.yellow(this.formatTestHeader(test, { | ||
indent: ' ' | ||
}))); | ||
} | ||
if (skipped) tokens.push(colors.yellow(` ${skipped} skipped`)); | ||
if (didNotRun) tokens.push(colors.yellow(` ${didNotRun} did not run`)); | ||
if (expected) tokens.push(colors.green(` ${expected} passed`) + colors.dim(` (${(0, _utilsBundle.ms)(this.result.duration)})`)); | ||
if (fatalErrors.length && expected + unexpected.length + interrupted.length + flaky.length > 0) tokens.push(colors.red(` ${fatalErrors.length === 1 ? '1 error was not a part of any test' : fatalErrors.length + ' errors were not a part of any test'}, see above for details`)); | ||
if (skipped) tokens.push(this.screen.colors.yellow(` ${skipped} skipped`)); | ||
if (didNotRun) tokens.push(this.screen.colors.yellow(` ${didNotRun} did not run`)); | ||
if (expected) tokens.push(this.screen.colors.green(` ${expected} passed`) + this.screen.colors.dim(` (${(0, _utilsBundle.ms)(this.result.duration)})`)); | ||
if (fatalErrors.length && expected + unexpected.length + interrupted.length + flaky.length > 0) tokens.push(this.screen.colors.red(` ${fatalErrors.length === 1 ? '1 error was not a part of any test' : fatalErrors.length + ' errors were not a part of any test'}, see above for details`)); | ||
return tokens.join('\n'); | ||
@@ -266,3 +308,3 @@ } | ||
failures.forEach((test, index) => { | ||
console.log(formatFailure(this.config, test, index + 1)); | ||
console.log(this.formatFailure(test, index + 1)); | ||
}); | ||
@@ -273,5 +315,5 @@ } | ||
slowTests.forEach(([file, duration]) => { | ||
console.log(colors.yellow(' Slow test file: ') + file + colors.yellow(` (${(0, _utilsBundle.ms)(duration)})`)); | ||
console.log(this.screen.colors.yellow(' Slow test file: ') + file + this.screen.colors.yellow(` (${(0, _utilsBundle.ms)(duration)})`)); | ||
}); | ||
if (slowTests.length) console.log(colors.yellow(' Consider running tests from slow files in parallel, see https://playwright.dev/docs/test-parallel.')); | ||
if (slowTests.length) console.log(this.screen.colors.yellow(' Consider running tests from slow files in parallel, see https://playwright.dev/docs/test-parallel.')); | ||
} | ||
@@ -284,7 +326,19 @@ _printSummary(summary) { | ||
} | ||
formatTestTitle(test, step, omitLocation = false) { | ||
return formatTestTitle(this.screen, this.config, test, step, omitLocation); | ||
} | ||
formatTestHeader(test, options = {}) { | ||
return formatTestHeader(this.screen, this.config, test, options); | ||
} | ||
formatFailure(test, index) { | ||
return formatFailure(this.screen, this.config, test, index); | ||
} | ||
formatError(error) { | ||
return formatError(this.screen, error); | ||
} | ||
} | ||
exports.BaseReporter = BaseReporter; | ||
function formatFailure(config, test, index) { | ||
exports.TerminalReporter = TerminalReporter; | ||
function formatFailure(screen, config, test, index) { | ||
const lines = []; | ||
const header = formatTestHeader(config, test, { | ||
const header = formatTestHeader(screen, config, test, { | ||
indent: ' ', | ||
@@ -294,6 +348,6 @@ index, | ||
}); | ||
lines.push(colors.red(header)); | ||
lines.push(screen.colors.red(header)); | ||
for (const result of test.results) { | ||
const resultLines = []; | ||
const errors = formatResultFailure(test, result, ' ', colors.enabled); | ||
const errors = formatResultFailure(screen, test, result, ' '); | ||
if (!errors.length) continue; | ||
@@ -303,3 +357,3 @@ const retryLines = []; | ||
retryLines.push(''); | ||
retryLines.push(colors.gray(separator(` Retry #${result.retry}`))); | ||
retryLines.push(screen.colors.gray(separator(screen, ` Retry #${result.retry}`))); | ||
} | ||
@@ -313,12 +367,12 @@ resultLines.push(...retryLines); | ||
resultLines.push(''); | ||
resultLines.push(colors.cyan(separator(` attachment #${i + 1}: ${attachment.name} (${attachment.contentType})`))); | ||
resultLines.push(screen.colors.cyan(separator(screen, ` attachment #${i + 1}: ${attachment.name} (${attachment.contentType})`))); | ||
if (attachment.path) { | ||
const relativePath = _path.default.relative(process.cwd(), attachment.path); | ||
resultLines.push(colors.cyan(` ${relativePath}`)); | ||
resultLines.push(screen.colors.cyan(` ${relativePath}`)); | ||
// Make this extensible | ||
if (attachment.name === 'trace') { | ||
const packageManagerCommand = (0, _utils.getPackageManagerExecCommand)(); | ||
resultLines.push(colors.cyan(` Usage:`)); | ||
resultLines.push(screen.colors.cyan(` Usage:`)); | ||
resultLines.push(''); | ||
resultLines.push(colors.cyan(` ${packageManagerCommand} playwright show-trace ${quotePathIfNeeded(relativePath)}`)); | ||
resultLines.push(screen.colors.cyan(` ${packageManagerCommand} playwright show-trace ${quotePathIfNeeded(relativePath)}`)); | ||
resultLines.push(''); | ||
@@ -330,6 +384,6 @@ } | ||
if (text.length > 300) text = text.slice(0, 300) + '...'; | ||
for (const line of text.split('\n')) resultLines.push(colors.cyan(` ${line}`)); | ||
for (const line of text.split('\n')) resultLines.push(screen.colors.cyan(` ${line}`)); | ||
} | ||
} | ||
resultLines.push(colors.cyan(separator(' '))); | ||
resultLines.push(screen.colors.cyan(separator(screen, ' '))); | ||
} | ||
@@ -341,7 +395,7 @@ lines.push(...resultLines); | ||
} | ||
function formatRetry(result) { | ||
function formatRetry(screen, result) { | ||
const retryLines = []; | ||
if (result.retry) { | ||
retryLines.push(''); | ||
retryLines.push(colors.gray(separator(` Retry #${result.retry}`))); | ||
retryLines.push(screen.colors.gray(separator(screen, ` Retry #${result.retry}`))); | ||
} | ||
@@ -354,7 +408,7 @@ return retryLines; | ||
} | ||
function formatResultFailure(test, result, initialIndent, highlightCode) { | ||
function formatResultFailure(screen, test, result, initialIndent) { | ||
const errorDetails = []; | ||
if (result.status === 'passed' && test.expectedStatus === 'failed') { | ||
errorDetails.push({ | ||
message: indent(colors.red(`Expected to fail, but passed.`), initialIndent) | ||
message: indent(screen.colors.red(`Expected to fail, but passed.`), initialIndent) | ||
}); | ||
@@ -364,7 +418,7 @@ } | ||
errorDetails.push({ | ||
message: indent(colors.red(`Test was interrupted.`), initialIndent) | ||
message: indent(screen.colors.red(`Test was interrupted.`), initialIndent) | ||
}); | ||
} | ||
for (const error of result.errors) { | ||
const formattedError = formatError(error, highlightCode); | ||
const formattedError = formatError(screen, error); | ||
errorDetails.push({ | ||
@@ -377,7 +431,8 @@ message: indent(formattedError.message, initialIndent), | ||
} | ||
function relativeFilePath(config, file) { | ||
return _path.default.relative(config.rootDir, file) || _path.default.basename(file); | ||
function relativeFilePath(screen, config, file) { | ||
if (screen.resolveFiles === 'cwd') return _path.default.relative(process.cwd(), file); | ||
return _path.default.relative(config.rootDir, file); | ||
} | ||
function relativeTestPath(config, test) { | ||
return relativeFilePath(config, test.location.file); | ||
function relativeTestPath(screen, config, test) { | ||
return relativeFilePath(screen, config, test.location.file); | ||
} | ||
@@ -388,7 +443,7 @@ function stepSuffix(step) { | ||
} | ||
function formatTestTitle(config, test, step, omitLocation = false) { | ||
function formatTestTitle(screen, config, test, step, omitLocation = false) { | ||
// root, project, file, ...describes, test | ||
const [, projectName,, ...titles] = test.titlePath(); | ||
let location; | ||
if (omitLocation) location = `${relativeTestPath(config, test)}`;else location = `${relativeTestPath(config, test)}:${test.location.line}:${test.location.column}`; | ||
if (omitLocation) location = `${relativeTestPath(screen, config, test)}`;else location = `${relativeTestPath(screen, config, test)}:${test.location.line}:${test.location.column}`; | ||
const projectTitle = projectName ? `[${projectName}] › ` : ''; | ||
@@ -399,4 +454,4 @@ const testTitle = `${projectTitle}${location} › ${titles.join(' › ')}`; | ||
} | ||
function formatTestHeader(config, test, options = {}) { | ||
const title = formatTestTitle(config, test); | ||
function formatTestHeader(screen, config, test, options = {}) { | ||
const title = formatTestTitle(screen, config, test); | ||
const header = `${options.indent || ''}${options.index ? options.index + ') ' : ''}${title}`; | ||
@@ -423,5 +478,5 @@ let fullHeader = header; | ||
} | ||
return separator(fullHeader); | ||
return separator(screen, fullHeader); | ||
} | ||
function formatError(error, highlightCode) { | ||
function formatError(screen, error) { | ||
const message = error.message || error.value || ''; | ||
@@ -440,10 +495,10 @@ const stack = error.stack; | ||
let snippet = error.snippet; | ||
if (!highlightCode) snippet = stripAnsiEscapes(snippet); | ||
if (!screen.colors.enabled) snippet = stripAnsiEscapes(snippet); | ||
tokens.push(''); | ||
tokens.push(snippet); | ||
} | ||
if (parsedStack && parsedStack.stackLines.length) tokens.push(colors.dim(parsedStack.stackLines.join('\n'))); | ||
if (parsedStack && parsedStack.stackLines.length) tokens.push(screen.colors.dim(parsedStack.stackLines.join('\n'))); | ||
let location = error.location; | ||
if (parsedStack && !location) location = parsedStack.location; | ||
if (error.cause) tokens.push(colors.dim('[cause]: ') + formatError(error.cause, highlightCode).message); | ||
if (error.cause) tokens.push(screen.colors.dim('[cause]: ') + formatError(screen, error.cause).message); | ||
return { | ||
@@ -454,6 +509,6 @@ location, | ||
} | ||
function separator(text = '') { | ||
function separator(screen, text = '') { | ||
if (text) text += ' '; | ||
const columns = Math.min(100, ttyWidth || 100); | ||
return text + colors.dim('─'.repeat(Math.max(0, columns - text.length))); | ||
const columns = Math.min(100, screen.ttyWidth || 100); | ||
return text + screen.colors.dim('─'.repeat(Math.max(0, columns - text.length))); | ||
} | ||
@@ -460,0 +515,0 @@ function indent(lines, tab) { |
@@ -24,3 +24,3 @@ "use strict"; | ||
class DotReporter extends _base.BaseReporter { | ||
class DotReporter extends _base.TerminalReporter { | ||
constructor(...args) { | ||
@@ -50,7 +50,7 @@ super(...args); | ||
if (result.status === 'skipped') { | ||
process.stdout.write(_base.colors.yellow('°')); | ||
process.stdout.write(this.screen.colors.yellow('°')); | ||
return; | ||
} | ||
if (this.willRetry(test)) { | ||
process.stdout.write(_base.colors.gray('×')); | ||
process.stdout.write(this.screen.colors.gray('×')); | ||
return; | ||
@@ -60,9 +60,9 @@ } | ||
case 'expected': | ||
process.stdout.write(_base.colors.green('·')); | ||
process.stdout.write(this.screen.colors.green('·')); | ||
break; | ||
case 'unexpected': | ||
process.stdout.write(_base.colors.red(result.status === 'timedOut' ? 'T' : 'F')); | ||
process.stdout.write(this.screen.colors.red(result.status === 'timedOut' ? 'T' : 'F')); | ||
break; | ||
case 'flaky': | ||
process.stdout.write(_base.colors.yellow('±')); | ||
process.stdout.write(this.screen.colors.yellow('±')); | ||
break; | ||
@@ -73,3 +73,3 @@ } | ||
super.onError(error); | ||
console.log('\n' + (0, _base.formatError)(error, _base.colors.enabled).message); | ||
console.log('\n' + this.formatError(error).message); | ||
this._counter = 0; | ||
@@ -76,0 +76,0 @@ } |
@@ -46,6 +46,10 @@ "use strict"; | ||
} | ||
class GitHubReporter extends _base.BaseReporter { | ||
constructor(...args) { | ||
super(...args); | ||
class GitHubReporter extends _base.TerminalReporter { | ||
constructor(options = {}) { | ||
super(options); | ||
this.githubLogger = new GitHubLogger(); | ||
this.screen = { | ||
...this.screen, | ||
colors: _base.noColors | ||
}; | ||
} | ||
@@ -60,3 +64,3 @@ printsToStdio() { | ||
onError(error) { | ||
const errorMessage = (0, _base.formatError)(error, false).message; | ||
const errorMessage = this.formatError(error).message; | ||
this.githubLogger.error(errorMessage); | ||
@@ -87,4 +91,4 @@ } | ||
failures.forEach((test, index) => { | ||
const title = (0, _base.formatTestTitle)(this.config, test); | ||
const header = (0, _base.formatTestHeader)(this.config, test, { | ||
const title = this.formatTestTitle(test); | ||
const header = this.formatTestHeader(test, { | ||
indent: ' ', | ||
@@ -95,3 +99,3 @@ index: index + 1, | ||
for (const result of test.results) { | ||
const errors = (0, _base.formatResultFailure)(test, result, ' ', _base.colors.enabled); | ||
const errors = (0, _base.formatResultFailure)(this.screen, test, result, ' '); | ||
for (const error of errors) { | ||
@@ -107,3 +111,3 @@ var _error$location; | ||
} | ||
const message = [header, ...(0, _base.formatRetry)(result), error.message].join('\n'); | ||
const message = [header, ...(0, _base.formatRetry)(this.screen, result), error.message].join('\n'); | ||
this.githubLogger.error(message, options); | ||
@@ -110,0 +114,0 @@ } |
@@ -81,6 +81,6 @@ "use strict"; | ||
reportedWarnings.add(key); | ||
console.log(_base.colors.red(`Configuration Error: HTML reporter output folder clashes with the tests output folder:`)); | ||
console.log(_utilsBundle.colors.red(`Configuration Error: HTML reporter output folder clashes with the tests output folder:`)); | ||
console.log(` | ||
html reporter folder: ${_base.colors.bold(outputFolder)} | ||
test results folder: ${_base.colors.bold(project.outputDir)}`); | ||
html reporter folder: ${_utilsBundle.colors.bold(outputFolder)} | ||
test results folder: ${_utilsBundle.colors.bold(project.outputDir)}`); | ||
console.log(''); | ||
@@ -133,3 +133,3 @@ console.log(`HTML reporter will clear its output directory prior to being generated, which will lead to the artifact loss. | ||
console.log('To open last HTML report run:'); | ||
console.log(_base.colors.cyan(` | ||
console.log(_utilsBundle.colors.cyan(` | ||
${packageManagerCommand} playwright show-report${relativeReportPath}${hostArg}${portArg} | ||
@@ -150,3 +150,3 @@ `)); | ||
if (!isHtmlReportOption(htmlOpenEnv)) { | ||
console.log(_base.colors.red(`Configuration Error: HTML reporter Invalid value for PLAYWRIGHT_HTML_OPEN: ${htmlOpenEnv}. Valid values are: ${htmlReportOptions.join(', ')}`)); | ||
console.log(_utilsBundle.colors.red(`Configuration Error: HTML reporter Invalid value for PLAYWRIGHT_HTML_OPEN: ${htmlOpenEnv}. Valid values are: ${htmlReportOptions.join(', ')}`)); | ||
return undefined; | ||
@@ -165,3 +165,3 @@ } | ||
} catch (e) { | ||
console.log(_base.colors.red(`No report found at "${folder}"`)); | ||
console.log(_utilsBundle.colors.red(`No report found at "${folder}"`)); | ||
(0, _utils.gracefullyProcessExitDoNotHang)(1); | ||
@@ -178,3 +178,3 @@ return; | ||
console.log(''); | ||
console.log(_base.colors.cyan(` Serving HTML report at ${url}. Press Ctrl+C to quit.`)); | ||
console.log(_utilsBundle.colors.cyan(` Serving HTML report at ${url}. Press Ctrl+C to quit.`)); | ||
if (testId) url += `#?testId=${testId}`; | ||
@@ -290,3 +290,3 @@ url = url.replace('0.0.0.0', 'localhost'); | ||
}, | ||
errors: topLevelErrors.map(error => (0, _base.formatError)(error, true).message) | ||
errors: topLevelErrors.map(error => (0, _base.formatError)(_base.internalScreen, error).message) | ||
}; | ||
@@ -497,3 +497,3 @@ htmlReport.files.sort((f1, f2) => { | ||
steps: dedupeSteps(result.steps).map(s => this._createTestStep(s, result)), | ||
errors: (0, _base.formatResultFailure)(test, result, '', true).map(error => error.message), | ||
errors: (0, _base.formatResultFailure)(_base.internalScreen, test, result, '').map(error => error.message), | ||
status: result.status, | ||
@@ -500,0 +500,0 @@ attachments: this._serializeAttachments([...result.attachments, ...result.stdout.map(m => stdioAttachment(m, 'stdout')), ...result.stderr.map(m => stdioAttachment(m, 'stderr'))]) |
@@ -126,3 +126,3 @@ "use strict"; | ||
if (!file || _fs.default.realpathSync(file) !== location.file) { | ||
tokens.push(_base.colors.gray(` at `) + `${(0, _base.relativeFilePath)(config, location.file)}:${location.line}`); | ||
tokens.push(_base.internalScreen.colors.gray(` at `) + `${(0, _base.relativeFilePath)(_base.internalScreen, config, location.file)}:${location.line}`); | ||
tokens.push(''); | ||
@@ -129,0 +129,0 @@ } |
@@ -206,3 +206,3 @@ "use strict"; | ||
_serializeError(error) { | ||
return (0, _base.formatError)(error, true); | ||
return (0, _base.formatError)(_base.nonTerminalScreen, error); | ||
} | ||
@@ -209,0 +209,0 @@ _serializeTestStep(step) { |
@@ -170,3 +170,3 @@ "use strict"; | ||
}, | ||
text: (0, _base.stripAnsiEscapes)((0, _base.formatFailure)(this.config, test)) | ||
text: (0, _base.stripAnsiEscapes)((0, _base.formatFailure)(_base.nonTerminalScreen, this.config, test)) | ||
}); | ||
@@ -173,0 +173,0 @@ } |
@@ -24,3 +24,3 @@ "use strict"; | ||
class LineReporter extends _base.BaseReporter { | ||
class LineReporter extends _base.TerminalReporter { | ||
constructor(...args) { | ||
@@ -55,3 +55,3 @@ super(...args); | ||
// Write new header for the output. | ||
const title = _base.colors.dim((0, _base.formatTestTitle)(this.config, test)); | ||
const title = this.screen.colors.dim(this.formatTestTitle(test)); | ||
stream.write(this.fitToScreen(title) + `\n`); | ||
@@ -78,3 +78,3 @@ this._lastTest = test; | ||
if (!process.env.PW_TEST_DEBUG_REPORTERS) process.stdout.write(`\u001B[1A\u001B[2K`); | ||
console.log((0, _base.formatFailure)(this.config, test, ++this._failures)); | ||
console.log(this.formatFailure(test, ++this._failures)); | ||
console.log(); | ||
@@ -86,4 +86,4 @@ } | ||
const prefix = `[${this._current}/${this.totalTestCount}]${retriesPrefix} `; | ||
const currentRetrySuffix = result.retry ? _base.colors.yellow(` (retry #${result.retry})`) : ''; | ||
const title = (0, _base.formatTestTitle)(this.config, test, step) + currentRetrySuffix; | ||
const currentRetrySuffix = result.retry ? this.screen.colors.yellow(` (retry #${result.retry})`) : ''; | ||
const title = this.formatTestTitle(test, step) + currentRetrySuffix; | ||
if (process.env.PW_TEST_DEBUG_REPORTERS) process.stdout.write(`${prefix + title}\n`);else process.stdout.write(`\u001B[1A\u001B[2K${prefix + this.fitToScreen(title, prefix)}\n`); | ||
@@ -93,3 +93,3 @@ } | ||
super.onError(error); | ||
const message = (0, _base.formatError)(error, _base.colors.enabled).message + '\n'; | ||
const message = this.formatError(error).message + '\n'; | ||
if (!process.env.PW_TEST_DEBUG_REPORTERS && this._didBegin) process.stdout.write(`\u001B[1A\u001B[2K`); | ||
@@ -96,0 +96,0 @@ process.stdout.write(message); |
@@ -30,3 +30,3 @@ "use strict"; | ||
const NEGATIVE_STATUS_MARK = DOES_NOT_SUPPORT_UTF8_IN_TERMINAL ? 'x' : '✘'; | ||
class ListReporter extends _base.BaseReporter { | ||
class ListReporter extends _base.TerminalReporter { | ||
constructor(options = {}) { | ||
@@ -55,7 +55,7 @@ super(); | ||
this._resultIndex.set(result, index); | ||
if (!_base.isTTY) return; | ||
if (!this.screen.isTTY) return; | ||
this._maybeWriteNewLine(); | ||
this._testRows.set(test, this._lastRow); | ||
const prefix = this._testPrefix(index, ''); | ||
const line = _base.colors.dim((0, _base.formatTestTitle)(this.config, test)) + this._retrySuffix(result); | ||
const line = this.screen.colors.dim(this.formatTestTitle(test)) + this._retrySuffix(result); | ||
this._appendLine(line, prefix); | ||
@@ -82,3 +82,3 @@ } | ||
const testIndex = this._resultIndex.get(result) || ''; | ||
if (!_base.isTTY) return; | ||
if (!this.screen.isTTY) return; | ||
if (this._printSteps) { | ||
@@ -88,6 +88,6 @@ this._maybeWriteNewLine(); | ||
const prefix = this._testPrefix(this.getStepIndex(testIndex, result, step), ''); | ||
const line = test.title + _base.colors.dim((0, _base.stepSuffix)(step)); | ||
const line = test.title + this.screen.colors.dim((0, _base.stepSuffix)(step)); | ||
this._appendLine(line, prefix); | ||
} else { | ||
this._updateLine(this._testRows.get(test), _base.colors.dim((0, _base.formatTestTitle)(this.config, test, step)) + this._retrySuffix(result), this._testPrefix(testIndex, '')); | ||
this._updateLine(this._testRows.get(test), this.screen.colors.dim(this.formatTestTitle(test, step)) + this._retrySuffix(result), this._testPrefix(testIndex, '')); | ||
} | ||
@@ -99,11 +99,11 @@ } | ||
if (!this._printSteps) { | ||
if (_base.isTTY) this._updateLine(this._testRows.get(test), _base.colors.dim((0, _base.formatTestTitle)(this.config, test, step.parent)) + this._retrySuffix(result), this._testPrefix(testIndex, '')); | ||
if (this.screen.isTTY) this._updateLine(this._testRows.get(test), this.screen.colors.dim(this.formatTestTitle(test, step.parent)) + this._retrySuffix(result), this._testPrefix(testIndex, '')); | ||
return; | ||
} | ||
const index = this.getStepIndex(testIndex, result, step); | ||
const title = _base.isTTY ? test.title + _base.colors.dim((0, _base.stepSuffix)(step)) : (0, _base.formatTestTitle)(this.config, test, step); | ||
const title = this.screen.isTTY ? test.title + this.screen.colors.dim((0, _base.stepSuffix)(step)) : this.formatTestTitle(test, step); | ||
const prefix = this._testPrefix(index, ''); | ||
let text = ''; | ||
if (step.error) text = _base.colors.red(title);else text = title; | ||
text += _base.colors.dim(` (${(0, _utilsBundle.ms)(step.duration)})`); | ||
if (step.error) text = this.screen.colors.red(title);else text = title; | ||
text += this.screen.colors.dim(` (${(0, _utilsBundle.ms)(step.duration)})`); | ||
this._updateOrAppendLine(this._stepRows.get(step), text, prefix); | ||
@@ -119,3 +119,3 @@ } | ||
this._needNewLine = text[text.length - 1] !== '\n'; | ||
if (!_base.ttyWidth) return; | ||
if (!this.screen.ttyWidth) return; | ||
for (const ch of text) { | ||
@@ -128,3 +128,3 @@ if (ch === '\n') { | ||
++this._lastColumn; | ||
if (this._lastColumn > _base.ttyWidth) { | ||
if (this._lastColumn > this.screen.ttyWidth) { | ||
this._lastColumn = 0; | ||
@@ -143,3 +143,3 @@ ++this._lastRow; | ||
super.onTestEnd(test, result); | ||
const title = (0, _base.formatTestTitle)(this.config, test); | ||
const title = this.formatTestTitle(test); | ||
let prefix = ''; | ||
@@ -156,15 +156,15 @@ let text = ''; | ||
if (result.status === 'skipped') { | ||
prefix = this._testPrefix(index, _base.colors.green('-')); | ||
prefix = this._testPrefix(index, this.screen.colors.green('-')); | ||
// Do not show duration for skipped. | ||
text = _base.colors.cyan(title) + this._retrySuffix(result); | ||
text = this.screen.colors.cyan(title) + this._retrySuffix(result); | ||
} else { | ||
const statusMark = result.status === 'passed' ? POSITIVE_STATUS_MARK : NEGATIVE_STATUS_MARK; | ||
if (result.status === test.expectedStatus) { | ||
prefix = this._testPrefix(index, _base.colors.green(statusMark)); | ||
prefix = this._testPrefix(index, this.screen.colors.green(statusMark)); | ||
text = title; | ||
} else { | ||
prefix = this._testPrefix(index, _base.colors.red(statusMark)); | ||
text = _base.colors.red(title); | ||
prefix = this._testPrefix(index, this.screen.colors.red(statusMark)); | ||
text = this.screen.colors.red(title); | ||
} | ||
text += this._retrySuffix(result) + _base.colors.dim(` (${(0, _utilsBundle.ms)(result.duration)})`); | ||
text += this._retrySuffix(result) + this.screen.colors.dim(` (${(0, _utilsBundle.ms)(result.duration)})`); | ||
} | ||
@@ -174,3 +174,3 @@ this._updateOrAppendLine(this._testRows.get(test), text, prefix); | ||
_updateOrAppendLine(row, text, prefix) { | ||
if (_base.isTTY) { | ||
if (this.screen.isTTY) { | ||
this._updateLine(row, text, prefix); | ||
@@ -207,6 +207,6 @@ } else { | ||
const statusMarkLength = (0, _base.stripAnsiEscapes)(statusMark).length; | ||
return ' ' + statusMark + ' '.repeat(3 - statusMarkLength) + _base.colors.dim(index + ' '); | ||
return ' ' + statusMark + ' '.repeat(3 - statusMarkLength) + this.screen.colors.dim(index + ' '); | ||
} | ||
_retrySuffix(result) { | ||
return result.retry ? _base.colors.yellow(` (retry #${result.retry})`) : ''; | ||
return result.retry ? this.screen.colors.yellow(` (retry #${result.retry})`) : ''; | ||
} | ||
@@ -216,3 +216,3 @@ onError(error) { | ||
this._maybeWriteNewLine(); | ||
const message = (0, _base.formatError)(error, _base.colors.enabled).message + '\n'; | ||
const message = this.formatError(error).message + '\n'; | ||
this._updateLineCountAndNewLineFlagForOutput(message); | ||
@@ -219,0 +219,0 @@ process.stdout.write(message); |
@@ -28,3 +28,3 @@ "use strict"; | ||
class MarkdownReporter extends _base.BaseReporter { | ||
class MarkdownReporter extends _base.TerminalReporter { | ||
constructor(options) { | ||
@@ -73,3 +73,3 @@ super(); | ||
_printTestList(prefix, tests, lines, suffix) { | ||
for (const test of tests) lines.push(`${prefix} ${(0, _base.formatTestTitle)(this.config, test)}${suffix || ''}`); | ||
for (const test of tests) lines.push(`${prefix} ${this.formatTestTitle(test)}${suffix || ''}`); | ||
lines.push(``); | ||
@@ -76,0 +76,0 @@ } |
@@ -90,3 +90,3 @@ "use strict"; | ||
} | ||
function createErrorCollectingReporter(writeToConsole) { | ||
function createErrorCollectingReporter(screen, writeToConsole) { | ||
const errors = []; | ||
@@ -97,3 +97,3 @@ return { | ||
errors.push(error); | ||
if (writeToConsole) process.stdout.write((0, _base.formatError)(error, _base.colors.enabled).message + '\n'); | ||
if (writeToConsole) process.stdout.write((0, _base.formatError)(screen, error).message + '\n'); | ||
}, | ||
@@ -152,4 +152,4 @@ errors: () => errors | ||
// eslint-disable-next-line no-console | ||
console.error('\n' + (0, _base.formatError)(error, false).message); | ||
console.error('\n' + (0, _base.formatError)(_base.terminalScreen, error).message); | ||
} | ||
} |
@@ -14,2 +14,3 @@ "use strict"; | ||
var _lastRun = require("./lastRun"); | ||
var _base = require("../reporters/base"); | ||
/** | ||
@@ -83,3 +84,3 @@ * Copyright 2019 Google Inc. All rights reserved. | ||
async findRelatedTestFiles(files) { | ||
const errorReporter = (0, _reporters.createErrorCollectingReporter)(); | ||
const errorReporter = (0, _reporters.createErrorCollectingReporter)(_base.terminalScreen); | ||
const reporter = new _internalReporter.InternalReporter([errorReporter]); | ||
@@ -100,3 +101,3 @@ const status = await (0, _tasks.runTasks)(new _tasks.TestRun(this._config, reporter), [...(0, _tasks.createPluginSetupTasks)(this._config), (0, _tasks.createLoadTask)('in-process', { | ||
async runDevServer() { | ||
const reporter = new _internalReporter.InternalReporter([(0, _reporters.createErrorCollectingReporter)(true)]); | ||
const reporter = new _internalReporter.InternalReporter([(0, _reporters.createErrorCollectingReporter)(_base.terminalScreen, true)]); | ||
const status = await (0, _tasks.runTasks)(new _tasks.TestRun(this._config, reporter), [...(0, _tasks.createPluginSetupTasks)(this._config), (0, _tasks.createLoadTask)('in-process', { | ||
@@ -114,3 +115,3 @@ failOnLoadErrors: true, | ||
async clearCache() { | ||
const reporter = new _internalReporter.InternalReporter([(0, _reporters.createErrorCollectingReporter)(true)]); | ||
const reporter = new _internalReporter.InternalReporter([(0, _reporters.createErrorCollectingReporter)(_base.terminalScreen, true)]); | ||
const status = await (0, _tasks.runTasks)(new _tasks.TestRun(this._config, reporter), [...(0, _tasks.createPluginSetupTasks)(this._config), (0, _tasks.createClearCacheTask)(this._config)]); | ||
@@ -117,0 +118,0 @@ return { |
@@ -26,2 +26,3 @@ "use strict"; | ||
var _internalReporter = require("../reporters/internalReporter"); | ||
var _base = require("../reporters/base"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -407,3 +408,3 @@ /** | ||
async findRelatedTestFiles(params) { | ||
const errorReporter = (0, _reporters.createErrorCollectingReporter)(); | ||
const errorReporter = (0, _reporters.createErrorCollectingReporter)(_base.internalScreen); | ||
const reporter = new _internalReporter.InternalReporter([errorReporter]); | ||
@@ -410,0 +411,0 @@ const config = await this._loadConfigOrReportError(reporter); |
@@ -333,3 +333,3 @@ "use strict"; | ||
if (name === 'h') { | ||
process.stdout.write(`${(0, _base.separator)()} | ||
process.stdout.write(`${(0, _base.separator)(_base.terminalScreen)} | ||
Run tests | ||
@@ -383,3 +383,3 @@ ${_utilsBundle.colors.bold('enter')} ${_utilsBundle.colors.dim('run tests')} | ||
const lines = []; | ||
const sep = (0, _base.separator)(); | ||
const sep = (0, _base.separator)(_base.terminalScreen); | ||
lines.push('\x1Bc' + sep); | ||
@@ -391,3 +391,3 @@ lines.push(`${tokens.join(' ')}`); | ||
function printBufferPrompt(dirtyTestFiles, rootDir) { | ||
const sep = (0, _base.separator)(); | ||
const sep = (0, _base.separator)(_base.terminalScreen); | ||
process.stdout.write('\x1Bc'); | ||
@@ -404,3 +404,3 @@ process.stdout.write(`${sep}\n`); | ||
function printPrompt() { | ||
const sep = (0, _base.separator)(); | ||
const sep = (0, _base.separator)(_base.terminalScreen); | ||
process.stdout.write(` | ||
@@ -407,0 +407,0 @@ ${sep} |
{ | ||
"name": "playwright", | ||
"version": "1.50.0-alpha-2025-01-06", | ||
"version": "1.50.0-alpha-2025-01-07", | ||
"description": "A high-level API to automate web browsers", | ||
@@ -59,3 +59,3 @@ "repository": { | ||
"dependencies": { | ||
"playwright-core": "1.50.0-alpha-2025-01-06" | ||
"playwright-core": "1.50.0-alpha-2025-01-07" | ||
}, | ||
@@ -62,0 +62,0 @@ "optionalDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3173868
36270
+ Addedplaywright-core@1.50.0-alpha-2025-01-07(transitive)
- Removedplaywright-core@1.50.0-alpha-2025-01-06(transitive)