Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 33 additions & 31 deletions e2e/ci-helpers/generate-test-summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ function getStatusIcon(status: string): string {

function generateSummary(reportPath: string, reportName: string): void {
if (!fs.existsSync(reportPath)) {
console.log(`Report not found: ${reportPath}`);
console.error(`Report not found: ${reportPath}`);
return;
}

const fileContent = fs.readFileSync(reportPath, "utf-8");
if (!fileContent || fileContent.trim().length === 0) {
console.log(`Report is empty: ${reportPath}`);
console.error(`Report is empty: ${reportPath}`);
return;
}

Expand All @@ -46,13 +46,13 @@ function generateSummary(reportPath: string, reportName: string): void {
try {
report = JSON.parse(fileContent);
} catch (error) {
console.log(`Failed to parse report: ${reportPath}`);
console.log(`Error: ${error instanceof Error ? error.message : String(error)}`);
console.error(`Failed to parse report: ${reportPath}`);
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
return;
}

if (!report.suites || report.suites.length === 0) {
console.log(`No test suites found in report: ${reportPath}`);
if (report.suites.length === 0) {
console.error(`No test suites found in report: ${reportPath}`);
return;
}

Expand Down Expand Up @@ -81,8 +81,8 @@ function generateSummary(reportPath: string, reportName: string): void {
tests.sort((a, b) => b.duration - a.duration);

if (tests.length === 0) {
console.log(`\n## ${reportName} Summary\n`);
console.log(`No tests found in report.\n`);
process.stdout.write(`\n## ${reportName} Summary\n`);
process.stdout.write(`No tests found in report.\n`);
return;
}

Expand All @@ -98,57 +98,59 @@ function generateSummary(reportPath: string, reportName: string): void {
/**
* Output Summary
*/
console.log(`\n## ${reportName} Summary\n`);
console.log(`| Metric | Value |`);
console.log(`|--------|-------|`);
console.log(`| Total Tests | ${totalTests} |`);
console.log(`| Passed ✅ | ${passed} |`);
console.log(`| Failed ❌ | ${failed} |`);
console.log(`| Skipped | ${skipped} |`);
console.log(`| Timed Out | ${timedOut} |`);
console.log(`| Total Duration | ${formatDuration(totalDuration)} |`);
console.log(`| Average Duration | ${formatDuration(avgDuration)} |`);
console.log(``);
process.stdout.write(`\n## ${reportName} Summary\n`);
process.stdout.write(`| Metric | Value |\n`);
process.stdout.write(`|--------|-------|\n`);
process.stdout.write(`| Total Tests | ${totalTests} |\n`);
process.stdout.write(`| Passed ✅ | ${passed} |\n`);
process.stdout.write(`| Failed ❌ | ${failed} |\n`);
process.stdout.write(`| Skipped | ${skipped} |\n`);
process.stdout.write(`| Timed Out | ${timedOut} |\n`);
process.stdout.write(`| Total Duration | ${formatDuration(totalDuration)} |\n`);
process.stdout.write(`| Average Duration | ${formatDuration(avgDuration)} |\n`);
process.stdout.write(`\n`);

/**
* Slowest Tests
*/
console.log(`### Top 10 Slowest Tests\n`);
console.log(`| Status | Duration | Test | Retries |`);
console.log(`|--------|----------|------|---------|`);
process.stdout.write(`### Top 10 Slowest Tests\n`);
process.stdout.write(`| Status | Duration | Test | Retries |\n`);
process.stdout.write(`|--------|----------|------|---------|\n`);

tests.slice(0, 10).forEach((test) => {
const statusEmoji = getStatusIcon(test.status);
const retriesText = test.retries > 0 ? `🔄 ${test.retries}` : "-";
console.log(
`| ${statusEmoji} | ${formatDuration(test.duration)} | ${test.title} | ${retriesText} |`,
process.stdout.write(
`| ${statusEmoji} | ${formatDuration(test.duration)} | ${test.title} | ${retriesText} |\n`,
);
});

/**
* Failed Tests
*/
if (failed > 0) {
console.log(`\n### ❌ Failed Tests\n`);
console.log(`| Duration | Test | Retries |`);
console.log(`|----------|------|---------|`);
process.stdout.write(`\n### ❌ Failed Tests\n`);
process.stdout.write(`| Duration | Test | Retries |\n`);
process.stdout.write(`|----------|------|---------|\n`);

tests
.filter((t) => t.status === "failed")
.forEach((test) => {
const retriesText = test.retries > 0 ? `🔄 ${test.retries}` : "-";
console.log(`| ${formatDuration(test.duration)} | ${test.title} | ${retriesText} |`);
process.stdout.write(
`| ${formatDuration(test.duration)} | ${test.title} | ${retriesText} |\n`,
);
});
}

console.log("");
process.stdout.write("\n");
}

function main(): void {
const reportsDir = path.join(__dirname, "..", "reports");
console.log(`Generating E2E test summary from reports in: ${reportsDir}\n`);
process.stdout.write(`Generating E2E test summary from reports in: ${reportsDir}\n`);

console.log("# E2E Test Results Summary\n");
process.stdout.write("# E2E Test Results Summary\n");

// Desktop tests
const desktopReportPath = path.join(reportsDir, "desktop", "results.json");
Expand Down
2 changes: 1 addition & 1 deletion packages/suite-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"moment": "2.30.1",
"moment-duration-format": "2.3.2",
"moment-timezone": "0.6.0",
"monaco-editor": "0.54.0",
"monaco-editor": "0.55.1",
"monaco-editor-webpack-plugin": "7.1.1",
"nanoid": "5.1.6",
"natsort": "2.0.3",
Expand Down
Loading