build(deps): bump playwright from 1.49.1 to 1.50.1

This commit is contained in:
2025-02-21 17:22:03 -07:00
parent 79c9869e65
commit dc6d9c68a9
174 changed files with 3064 additions and 1955 deletions

View File

@@ -3,22 +3,20 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.colors = exports.BaseReporter = void 0;
exports.TerminalReporter = void 0;
exports.fitToWidth = fitToWidth;
exports.formatError = formatError;
exports.formatFailure = formatFailure;
exports.formatResultFailure = formatResultFailure;
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;
exports.relativeFilePath = relativeFilePath;
exports.resolveOutputFile = resolveOutputFile;
exports.separator = separator;
exports.stepSuffix = stepSuffix;
exports.stripAnsiEscapes = stripAnsiEscapes;
exports.ttyWidth = void 0;
exports.terminalScreen = void 0;
var _utilsBundle = require("playwright-core/lib/utilsBundle");
var _path = _interopRequireDefault(require("path"));
var _utils = require("playwright-core/lib/utils");
@@ -42,11 +40,49 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
*/
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;
let ttyWidth = process.stdout.columns || 0;
if (process.env.PLAYWRIGHT_FORCE_TTY === 'false' || process.env.PLAYWRIGHT_FORCE_TTY === '0') {
@@ -62,27 +98,33 @@ const {
}
let useColors = isTTY;
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,
ttyWidth,
colors
};
})();
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;
this.suite = void 0;
this.totalTestCount = 0;
@@ -123,7 +165,7 @@ class BaseReporter {
onTestEnd(test, result) {
if (result.status !== 'skipped' && result.status !== test.expectedStatus) ++this._failureCount;
const projectName = test.titlePath()[1];
const relativePath = relativeTestPath(this.config, test);
const relativePath = relativeTestPath(this.screen, this.config, test);
const fileAndProject = (projectName ? `[${projectName}] ` : '') + relativePath;
const entry = this.fileDurations.get(fileAndProject) || {
duration: 0,
@@ -140,18 +182,18 @@ class BaseReporter {
this.result = result;
}
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);
}
generateStartingMessage() {
var _this$config$metadata;
const jobs = (_this$config$metadata = this.config.metadata.actualWorkers) !== null && _this$config$metadata !== void 0 ? _this$config$metadata : this.config.workers;
const shardDetails = this.config.shard ? `, shard ${this.config.shard.current} of ${this.config.shard.total}` : '';
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}`);
}
getSlowTests() {
if (!this.config.reportSlowTests) return [];
@@ -173,27 +215,27 @@ class BaseReporter {
}) {
const tokens = [];
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: ' '
})));
}
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: ' '
})));
}
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');
}
generateSummary() {
@@ -251,15 +293,15 @@ class BaseReporter {
_printFailures(failures) {
console.log('');
failures.forEach((test, index) => {
console.log(formatFailure(this.config, test, index + 1));
console.log(this.formatFailure(test, index + 1));
});
}
_printSlowTests() {
const slowTests = this.getSlowTests();
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 splitting slow test files to speed up parallel execution'));
if (slowTests.length) console.log(this.screen.colors.yellow(' Consider running tests from slow files in parallel, see https://playwright.dev/docs/test-parallel.'));
}
_printSummary(summary) {
if (summary.trim()) console.log(summary);
@@ -267,24 +309,36 @@ class BaseReporter {
willRetry(test) {
return test.outcome() === 'unexpected' && test.results.length <= test.retries;
}
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: ' ',
index,
mode: 'error'
});
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;
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}`)));
}
resultLines.push(...retryLines);
resultLines.push(...errors.map(error => '\n' + error.message));
@@ -293,37 +347,37 @@ function formatFailure(config, test, index) {
const hasPrintableContent = attachment.contentType.startsWith('text/');
if (!attachment.path && !hasPrintableContent) continue;
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('');
}
} else {
if (attachment.contentType.startsWith('text/') && attachment.body) {
let text = attachment.body.toString();
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, ' ')));
}
lines.push(...resultLines);
}
lines.push('');
return lines.join('\n');
}
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}`)));
}
return retryLines;
}
@@ -331,20 +385,20 @@ function quotePathIfNeeded(path) {
if (/\s/.test(path)) return `"${path}"`;
return path;
}
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)
});
}
if (result.status === 'interrupted') {
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({
message: indent(formattedError.message, initialIndent),
location: formattedError.location
@@ -352,29 +406,29 @@ function formatResultFailure(test, result, initialIndent, highlightCode) {
}
return errorDetails;
}
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);
}
function stepSuffix(step) {
const stepTitles = step ? step.titlePath() : [];
return stepTitles.map(t => t.split('\n')[0]).map(t => ' ' + t).join('');
}
function formatTestTitle(config, test, step, omitLocation = false) {
var _step$location$line, _step$location, _step$location$column, _step$location2;
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)}:${(_step$location$line = step === null || step === void 0 || (_step$location = step.location) === null || _step$location === void 0 ? void 0 : _step$location.line) !== null && _step$location$line !== void 0 ? _step$location$line : test.location.line}:${(_step$location$column = step === null || step === void 0 || (_step$location2 = step.location) === null || _step$location2 === void 0 ? void 0 : _step$location2.column) !== null && _step$location$column !== void 0 ? _step$location$column : 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}] ` : '';
const testTitle = `${projectTitle}${location} ${titles.join(' ')}`;
const extraTags = test.tags.filter(t => !testTitle.includes(t));
return `${testTitle}${stepSuffix(step)}${extraTags.length ? ' ' + extraTags.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}`;
let fullHeader = header;
@@ -396,9 +450,9 @@ function formatTestHeader(config, test, options = {}) {
}
fullHeader = header + (stepPaths.size === 1 ? stepPaths.values().next().value : '');
}
return separator(fullHeader);
return separator(screen, fullHeader);
}
function formatError(error, highlightCode) {
function formatError(screen, error) {
const message = error.message || error.value || '';
const stack = error.stack;
if (!stack && !error.location) return {
@@ -412,23 +466,23 @@ function formatError(error, highlightCode) {
tokens.push((parsedStack === null || parsedStack === void 0 ? void 0 : parsedStack.message) || message);
if (error.snippet) {
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 {
location,
message: tokens.join('\n')
};
}
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)));
}
function indent(lines, tab) {
return lines.replace(/^(?=.+$)/gm, tab);

View File

@@ -21,7 +21,7 @@ var _base = require("./base");
* limitations under the License.
*/
class DotReporter extends _base.BaseReporter {
class DotReporter extends _base.TerminalReporter {
constructor(...args) {
super(...args);
this._counter = 0;
@@ -46,28 +46,28 @@ class DotReporter extends _base.BaseReporter {
}
++this._counter;
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;
}
switch (test.outcome()) {
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;
}
}
onError(error) {
super.onError(error);
console.log('\n' + (0, _base.formatError)(error, _base.colors.enabled).message);
console.log('\n' + this.formatError(error).message);
this._counter = 0;
}
async onEnd(result) {

View File

@@ -43,10 +43,14 @@ class GitHubLogger {
this._log(message, 'warning', options);
}
}
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
};
}
printsToStdio() {
return false;
@@ -56,7 +60,7 @@ class GitHubReporter extends _base.BaseReporter {
this._printAnnotations();
}
onError(error) {
const errorMessage = (0, _base.formatError)(error, false).message;
const errorMessage = this.formatError(error).message;
this.githubLogger.error(errorMessage);
}
_printAnnotations() {
@@ -82,14 +86,14 @@ class GitHubReporter extends _base.BaseReporter {
}
_printFailureAnnotations(failures) {
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: ' ',
index: index + 1,
mode: 'error'
});
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) {
var _error$location;
const options = {
@@ -100,7 +104,7 @@ class GitHubReporter extends _base.BaseReporter {
options.line = error.location.line;
options.col = error.location.column;
}
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);
}
}

View File

@@ -78,10 +78,10 @@ class HtmlReporter {
const key = outputFolder + '|' + project.outputDir;
if (reportedWarnings.has(key)) continue;
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('');
console.log(`HTML reporter will clear its output directory prior to being generated, which will lead to the artifact loss.
`);
@@ -129,7 +129,7 @@ class HtmlReporter {
const portArg = this._port ? ` --port ${this._port}` : '';
console.log('');
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}
`));
}
@@ -145,7 +145,7 @@ function getHtmlReportOptionProcessEnv() {
const htmlOpenEnv = process.env.PLAYWRIGHT_HTML_OPEN || process.env.PW_TEST_HTML_REPORT_OPEN;
if (!htmlOpenEnv) return undefined;
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;
}
return htmlOpenEnv;
@@ -159,7 +159,7 @@ async function showHTMLReport(reportFolder, host = 'localhost', port, testId) {
try {
(0, _utils.assert)(_fs.default.statSync(folder).isDirectory());
} 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);
return;
}
@@ -171,7 +171,7 @@ async function showHTMLReport(reportFolder, host = 'localhost', port, testId) {
});
let url = server.urlPrefix('human-readable');
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}`;
url = url.replace('0.0.0.0', 'localhost');
await (0, _utilsBundle.open)(url, {
@@ -217,12 +217,9 @@ class HtmlBuilder {
async build(metadata, projectSuites, result, topLevelErrors) {
const data = new Map();
for (const projectSuite of projectSuites) {
const testDir = projectSuite.project().testDir;
for (const fileSuite of projectSuite.suites) {
const fileName = this._relativeLocation(fileSuite.location).file;
// Preserve file ids computed off the testDir.
const relativeFile = _path.default.relative(testDir, fileSuite.location.file);
const fileId = (0, _utils.calculateSha1)((0, _utils.toPosixPath)(relativeFile)).slice(0, 20);
const fileId = (0, _utils.calculateSha1)((0, _utils.toPosixPath)(fileName)).slice(0, 20);
let fileEntry = data.get(fileId);
if (!fileEntry) {
fileEntry = {
@@ -285,7 +282,7 @@ class HtmlBuilder {
stats: {
...[...data.values()].reduce((a, e) => addStats(a, e.testFileSummary.stats), emptyStats())
},
errors: topLevelErrors.map(error => (0, _base.formatError)(error, true).message)
errors: topLevelErrors.map(error => (0, _base.formatError)(_base.internalScreen, error).message)
};
htmlReport.files.sort((f1, f2) => {
const w1 = f1.stats.unexpected * 1000 + f1.stats.flaky;
@@ -490,30 +487,37 @@ class HtmlBuilder {
duration: result.duration,
startTime: result.startTime.toISOString(),
retry: result.retry,
steps: dedupeSteps(result.steps).map(s => this._createTestStep(s)),
errors: (0, _base.formatResultFailure)(test, result, '', true).map(error => error.message),
steps: dedupeSteps(result.steps).map(s => this._createTestStep(s, result)),
errors: (0, _base.formatResultFailure)(_base.internalScreen, test, result, '').map(error => error.message),
status: result.status,
attachments: this._serializeAttachments([...result.attachments, ...result.stdout.map(m => stdioAttachment(m, 'stdout')), ...result.stderr.map(m => stdioAttachment(m, 'stderr'))])
};
}
_createTestStep(dedupedStep) {
_createTestStep(dedupedStep, result) {
var _step$error;
const {
step,
duration,
count
} = dedupedStep;
const result = {
const skipped = dedupedStep.step.category === 'test.step.skip';
const testStep = {
title: step.title,
startTime: step.startTime.toISOString(),
duration,
steps: dedupeSteps(step.steps).map(s => this._createTestStep(s)),
steps: dedupeSteps(step.steps).map(s => this._createTestStep(s, result)),
attachments: step.attachments.map(s => {
const index = result.attachments.indexOf(s);
if (index === -1) throw new Error('Unexpected, attachment not found');
return index;
}),
location: this._relativeLocation(step.location),
error: (_step$error = step.error) === null || _step$error === void 0 ? void 0 : _step$error.message,
count
count,
skipped
};
if (step.location) this._stepsInFile.set(step.location.file, result);
return result;
if (step.location) this._stepsInFile.set(step.location.file, testStep);
return testStep;
}
_relativeLocation(location) {
if (!location) return undefined;
@@ -572,17 +576,10 @@ function isTextContentType(contentType) {
return contentType.startsWith('text/') || contentType.startsWith('application/json');
}
function stdioAttachment(chunk, type) {
if (typeof chunk === 'string') {
return {
name: type,
contentType: 'text/plain',
body: chunk
};
}
return {
name: type,
contentType: 'application/octet-stream',
body: chunk
contentType: 'text/plain',
body: typeof chunk === 'string' ? chunk : chunk.toString('utf-8')
};
}
function dedupeSteps(steps) {

View File

@@ -123,7 +123,7 @@ function addLocationAndSnippetToError(config, error, file) {
});
// Convert /var/folders to /private/var/folders on Mac.
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('');
}
tokens.push(codeFrame);

View File

@@ -203,7 +203,7 @@ class JSONReporter {
return jsonResult;
}
_serializeError(error) {
return (0, _base.formatError)(error, true);
return (0, _base.formatError)(_base.nonTerminalScreen, error);
}
_serializeTestStep(step) {
const steps = step.steps.filter(s => s.category === 'test.step');

View File

@@ -167,7 +167,7 @@ class JUnitReporter {
message: `${_path.default.basename(test.location.file)}:${test.location.line}:${test.location.column} ${test.title}`,
type: 'FAILURE'
},
text: (0, _base.stripAnsiEscapes)((0, _base.formatFailure)(this.config, test))
text: (0, _base.stripAnsiEscapes)((0, _base.formatFailure)(_base.nonTerminalScreen, this.config, test))
});
}
const systemOut = [];

View File

@@ -21,7 +21,7 @@ var _base = require("./base");
* limitations under the License.
*/
class LineReporter extends _base.BaseReporter {
class LineReporter extends _base.TerminalReporter {
constructor(...args) {
super(...args);
this._current = 0;
@@ -51,7 +51,7 @@ class LineReporter extends _base.BaseReporter {
if (!process.env.PW_TEST_DEBUG_REPORTERS) stream.write(`\u001B[1A\u001B[2K`);
if (test && this._lastTest !== test) {
// 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`);
this._lastTest = test;
}
@@ -73,20 +73,20 @@ class LineReporter extends _base.BaseReporter {
super.onTestEnd(test, result);
if (!this.willRetry(test) && (test.outcome() === 'flaky' || test.outcome() === 'unexpected' || result.status === 'interrupted')) {
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();
}
}
_updateLine(test, result, step) {
const retriesPrefix = this.totalTestCount < this._current ? ` (retries)` : ``;
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`);
}
onError(error) {
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`);
process.stdout.write(message);
console.log();

View File

@@ -27,7 +27,7 @@ var _utils = require("playwright-core/lib/utils");
const DOES_NOT_SUPPORT_UTF8_IN_TERMINAL = process.platform === 'win32' && process.env.TERM_PROGRAM !== 'vscode' && !process.env.WT_SESSION;
const POSITIVE_STATUS_MARK = DOES_NOT_SUPPORT_UTF8_IN_TERMINAL ? 'ok' : '✓';
const NEGATIVE_STATUS_MARK = DOES_NOT_SUPPORT_UTF8_IN_TERMINAL ? 'x' : '✘';
class ListReporter extends _base.BaseReporter {
class ListReporter extends _base.TerminalReporter {
constructor(options = {}) {
super();
this._lastRow = 0;
@@ -51,11 +51,11 @@ class ListReporter extends _base.BaseReporter {
onTestBegin(test, result) {
const index = String(this._resultIndex.size + 1);
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);
}
onStdOut(chunk, test, result) {
@@ -77,41 +77,43 @@ class ListReporter extends _base.BaseReporter {
onStepBegin(test, result, step) {
if (step.category !== 'test.step') return;
const testIndex = this._resultIndex.get(result) || '';
if (!_base.isTTY) return;
if (!this.screen.isTTY) return;
if (this._printSteps) {
this._maybeWriteNewLine();
this._stepRows.set(step, this._lastRow);
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, ''));
}
}
onStepEnd(test, result, step) {
if (step.category !== 'test.step') return;
const testIndex = this._resultIndex.get(result) || '';
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);
}
_maybeWriteNewLine() {
if (this._needNewLine) {
this._needNewLine = false;
process.stdout.write('\n');
++this._lastRow;
this._lastColumn = 0;
}
}
_updateLineCountAndNewLineFlagForOutput(text) {
this._needNewLine = text[text.length - 1] !== '\n';
if (!_base.ttyWidth) return;
if (!this.screen.ttyWidth) return;
for (const ch of text) {
if (ch === '\n') {
this._lastColumn = 0;
@@ -119,7 +121,7 @@ class ListReporter extends _base.BaseReporter {
continue;
}
++this._lastColumn;
if (this._lastColumn > _base.ttyWidth) {
if (this._lastColumn > this.screen.ttyWidth) {
this._lastColumn = 0;
++this._lastRow;
}
@@ -133,7 +135,7 @@ class ListReporter extends _base.BaseReporter {
}
onTestEnd(test, result) {
super.onTestEnd(test, result);
const title = (0, _base.formatTestTitle)(this.config, test);
const title = this.formatTestTitle(test);
let prefix = '';
let text = '';
@@ -145,24 +147,24 @@ class ListReporter extends _base.BaseReporter {
this._resultIndex.set(result, index);
}
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)})`);
}
this._updateOrAppendLine(this._testRows.get(test), text, prefix);
}
_updateOrAppendLine(row, text, prefix) {
if (_base.isTTY) {
if (this.screen.isTTY) {
this._updateLine(row, text, prefix);
} else {
this._maybeWriteNewLine();
@@ -178,6 +180,7 @@ class ListReporter extends _base.BaseReporter {
process.stdout.write('\n');
}
++this._lastRow;
this._lastColumn = 0;
}
_updateLine(row, text, prefix) {
const line = prefix + this.fitToScreen(text, prefix);
@@ -194,15 +197,15 @@ class ListReporter extends _base.BaseReporter {
}
_testPrefix(index, statusMark) {
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})`) : '';
}
onError(error) {
super.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);
process.stdout.write(message);
}

View File

@@ -25,7 +25,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
* limitations under the License.
*/
class MarkdownReporter extends _base.BaseReporter {
class MarkdownReporter extends _base.TerminalReporter {
constructor(options) {
super();
this._options = void 0;
@@ -69,7 +69,7 @@ class MarkdownReporter extends _base.BaseReporter {
await _fs.default.promises.writeFile(reportFile, lines.join('\n'));
}
_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(``);
}
}

View File

@@ -102,7 +102,7 @@ class TeleReporterEmitter {
params: {
testId: test.id,
resultId: result[this._idSymbol],
step: this._serializeStepEnd(step)
step: this._serializeStepEnd(step, result)
}
});
}
@@ -245,11 +245,12 @@ class TeleReporterEmitter {
location: this._relativeLocation(step.location)
};
}
_serializeStepEnd(step) {
_serializeStepEnd(step, result) {
return {
id: step[this._idSymbol],
duration: step.duration,
error: step.error
error: step.error,
attachments: step.attachments.map(a => result.attachments.indexOf(a))
};
}
_relativeLocation(location) {