tdpw
Version:
CLI tool for uploading Playwright test reports to TestDino platform with Azure storage support
62 lines • 2.48 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformPlaywrightReport = transformPlaywrightReport;
/**
* Traverse Playwright report suites recursively and collect TestResult entries.
*/
function collectTests(suites, out) {
for (const suite of suites) {
// Recurse into nested suites
if (Array.isArray(suite.suites)) {
collectTests(suite.suites, out);
}
// Process specs (individual test definitions)
const specs = Array.isArray(suite.specs) ? suite.specs : [];
for (const spec of specs) {
const specFile = spec.file;
const specLine = spec.line;
const specColumn = spec.column;
const testId = spec.id;
const title = spec.title;
const runs = Array.isArray(spec.tests) ? spec.tests : [];
for (const run of runs) {
const results = Array.isArray(run.results) ? run.results : [];
for (const result of results) {
out.push({
testId,
title,
status: result.status,
duration: result.duration,
file: specFile,
line: specLine,
column: specColumn,
workerIndex: result.workerIndex,
parallelIndex: result.parallelIndex,
retry: result.retry,
startTime: result.startTime,
errors: Array.isArray(result.errors) ? result.errors : [],
stdout: Array.isArray(result.stdout) ? result.stdout : [],
stderr: Array.isArray(result.stderr) ? result.stderr : [],
attachments: Array.isArray(result.attachments) ? result.attachments : [],
});
}
}
}
}
}
/**
* Transform a parsed Playwright report into a flatter structure for uploading.
* @param report Parsed PlaywrightReport
*/
function transformPlaywrightReport(report) {
const tests = [];
collectTests(report.suites, tests);
// Extract project configurations if present
const projects = report.config.projects;
return {
stats: report.stats,
projects: Array.isArray(projects) ? projects : [],
tests,
};
}
//# sourceMappingURL=transformers.js.map