-
Notifications
You must be signed in to change notification settings - Fork 123
/
Copy pathmerge_html_reports.ts
36 lines (28 loc) · 1.29 KB
/
merge_html_reports.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import fs from 'fs';
import path from 'path';
import { mergeHTMLReports } from 'playwright-merge-html-reports';
void (async () => {
const inputReportPaths = fs
.readdirSync('./reports', { withFileTypes: true })
.filter((item) => item.isDirectory())
.map(({ name }) => path.resolve('reports', name));
if (inputReportPaths.length === 0) {
throw new Error('Error: No e2e reports found in e2e/reports/* to merge');
}
// eslint-disable-next-line no-console
console.log(`Merging ${inputReportPaths.length} playwright html reports:\n\n\t${inputReportPaths.join('\n\t')}\n`);
const config = {
outputFolderName: process.env.HTML_REPORT_DIR ?? 'merged_html_report',
outputBasePath: path.resolve(process.cwd(), process.env.HTML_REPORT_PATH ?? ''),
};
const outputDir = path.join(config.outputBasePath, config.outputFolderName);
fs.mkdirSync(outputDir, { recursive: true });
await mergeHTMLReports(inputReportPaths, config);
})();