2021-08-05 13:36:47 -07:00
|
|
|
/**
|
|
|
|
* Copyright (c) Microsoft Corporation.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2021-09-14 13:55:31 -07:00
|
|
|
import colors from 'colors/safe';
|
2021-08-05 13:36:47 -07:00
|
|
|
import fs from 'fs';
|
2021-09-14 13:55:31 -07:00
|
|
|
import open from 'open';
|
2021-08-05 13:36:47 -07:00
|
|
|
import path from 'path';
|
2021-10-20 11:51:12 -08:00
|
|
|
import { FullConfig, Suite } from '../../types/testReporter';
|
2021-10-22 15:59:52 -04:00
|
|
|
import { HttpServer } from 'playwright-core/lib/utils/httpServer';
|
|
|
|
import { calculateSha1, removeFolders } from 'playwright-core/lib/utils/utils';
|
2021-09-14 16:26:31 -07:00
|
|
|
import RawReporter, { JsonReport, JsonSuite, JsonTestCase, JsonTestResult, JsonTestStep, JsonAttachment } from './raw';
|
2021-10-14 20:09:41 -08:00
|
|
|
import assert from 'assert';
|
2021-08-05 13:36:47 -07:00
|
|
|
|
2021-09-14 13:55:31 -07:00
|
|
|
export type Stats = {
|
|
|
|
total: number;
|
|
|
|
expected: number;
|
|
|
|
unexpected: number;
|
|
|
|
flaky: number;
|
|
|
|
skipped: number;
|
|
|
|
ok: boolean;
|
2021-10-17 19:58:06 -08:00
|
|
|
duration: number;
|
2021-09-14 13:55:31 -07:00
|
|
|
};
|
|
|
|
|
2021-09-13 20:34:46 -07:00
|
|
|
export type Location = {
|
|
|
|
file: string;
|
|
|
|
line: number;
|
|
|
|
column: number;
|
2021-08-05 13:36:47 -07:00
|
|
|
};
|
|
|
|
|
2021-10-17 19:58:06 -08:00
|
|
|
export type HTMLReport = {
|
|
|
|
files: TestFileSummary[];
|
2021-10-18 07:03:04 -08:00
|
|
|
stats: Stats;
|
2021-10-17 19:58:06 -08:00
|
|
|
projectNames: string[];
|
2021-08-05 13:36:47 -07:00
|
|
|
};
|
|
|
|
|
2021-10-17 19:58:06 -08:00
|
|
|
export type TestFile = {
|
|
|
|
fileId: string;
|
|
|
|
fileName: string;
|
|
|
|
tests: TestCase[];
|
|
|
|
};
|
|
|
|
|
|
|
|
export type TestFileSummary = {
|
|
|
|
fileId: string;
|
|
|
|
fileName: string;
|
|
|
|
tests: TestCaseSummary[];
|
2021-09-14 13:55:31 -07:00
|
|
|
stats: Stats;
|
2021-08-05 13:36:47 -07:00
|
|
|
};
|
|
|
|
|
2021-10-17 19:58:06 -08:00
|
|
|
export type TestCaseSummary = {
|
2021-09-13 20:34:46 -07:00
|
|
|
testId: string,
|
2021-08-05 13:36:47 -07:00
|
|
|
title: string;
|
2021-10-17 19:58:06 -08:00
|
|
|
path: string[];
|
|
|
|
projectName: string;
|
2021-09-13 20:34:46 -07:00
|
|
|
location: Location;
|
2021-08-05 13:36:47 -07:00
|
|
|
outcome: 'skipped' | 'expected' | 'unexpected' | 'flaky';
|
2021-10-17 19:58:06 -08:00
|
|
|
duration: number;
|
2021-09-14 13:55:31 -07:00
|
|
|
ok: boolean;
|
2021-08-05 13:36:47 -07:00
|
|
|
};
|
|
|
|
|
2021-10-17 19:58:06 -08:00
|
|
|
export type TestCase = TestCaseSummary & {
|
2021-09-13 20:34:46 -07:00
|
|
|
results: TestResult[];
|
2021-08-07 15:47:03 -07:00
|
|
|
};
|
|
|
|
|
2021-10-17 19:58:06 -08:00
|
|
|
export type TestAttachment = JsonAttachment;
|
|
|
|
|
2021-09-13 20:34:46 -07:00
|
|
|
export type TestResult = {
|
2021-08-05 13:36:47 -07:00
|
|
|
retry: number;
|
|
|
|
startTime: string;
|
|
|
|
duration: number;
|
2021-09-13 20:34:46 -07:00
|
|
|
steps: TestStep[];
|
|
|
|
error?: string;
|
2021-09-14 16:26:31 -07:00
|
|
|
attachments: TestAttachment[];
|
2021-09-13 20:34:46 -07:00
|
|
|
status: 'passed' | 'failed' | 'timedOut' | 'skipped';
|
2021-08-05 13:36:47 -07:00
|
|
|
};
|
|
|
|
|
2021-09-13 20:34:46 -07:00
|
|
|
export type TestStep = {
|
2021-08-05 13:36:47 -07:00
|
|
|
title: string;
|
|
|
|
startTime: string;
|
|
|
|
duration: number;
|
2021-10-18 21:14:01 -08:00
|
|
|
location?: Location;
|
|
|
|
snippet?: string;
|
2021-09-13 20:34:46 -07:00
|
|
|
error?: string;
|
|
|
|
steps: TestStep[];
|
2021-08-05 13:36:47 -07:00
|
|
|
};
|
|
|
|
|
2021-10-17 19:58:06 -08:00
|
|
|
type TestEntry = {
|
|
|
|
testCase: TestCase;
|
|
|
|
testCaseSummary: TestCaseSummary
|
|
|
|
};
|
|
|
|
|
2021-08-07 15:47:03 -07:00
|
|
|
class HtmlReporter {
|
|
|
|
private config!: FullConfig;
|
|
|
|
private suite!: Suite;
|
2021-10-15 07:15:30 -08:00
|
|
|
private _outputFolder: string | undefined;
|
2021-10-29 15:24:08 -08:00
|
|
|
private _open: 'always' | 'never' | 'on-failure';
|
2021-10-15 07:15:30 -08:00
|
|
|
|
2021-10-29 15:24:08 -08:00
|
|
|
constructor(options: { outputFolder?: string, open?: 'always' | 'never' | 'on-failure' } = {}) {
|
2021-10-15 07:15:30 -08:00
|
|
|
// TODO: resolve relative to config.
|
|
|
|
this._outputFolder = options.outputFolder;
|
2021-10-29 15:24:08 -08:00
|
|
|
this._open = options.open || 'on-failure';
|
2021-10-15 07:15:30 -08:00
|
|
|
}
|
2021-08-07 15:47:03 -07:00
|
|
|
|
2021-08-10 17:06:25 -07:00
|
|
|
onBegin(config: FullConfig, suite: Suite) {
|
|
|
|
this.config = config;
|
|
|
|
this.suite = suite;
|
2021-08-07 15:47:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
async onEnd() {
|
2021-09-13 20:34:46 -07:00
|
|
|
const projectSuites = this.suite.suites;
|
|
|
|
const reports = projectSuites.map(suite => {
|
|
|
|
const rawReporter = new RawReporter();
|
|
|
|
const report = rawReporter.generateProjectReport(this.config, suite);
|
|
|
|
return report;
|
2021-08-07 15:47:03 -07:00
|
|
|
});
|
2021-10-15 07:15:30 -08:00
|
|
|
const reportFolder = htmlReportFolder(this._outputFolder);
|
2021-09-14 13:55:31 -07:00
|
|
|
await removeFolders([reportFolder]);
|
2021-10-14 20:09:41 -08:00
|
|
|
const builder = new HtmlBuilder(reportFolder, this.config.rootDir);
|
2021-11-01 09:54:53 -07:00
|
|
|
const { ok, singleTestId } = builder.build(reports);
|
2021-10-17 19:58:06 -08:00
|
|
|
|
2021-10-29 15:24:08 -08:00
|
|
|
if (process.env.PWTEST_SKIP_TEST_OUTPUT || process.env.CI)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const shouldOpen = this._open === 'always' || (!ok && this._open === 'on-failure');
|
|
|
|
if (shouldOpen) {
|
2021-11-01 09:54:53 -07:00
|
|
|
await showHTMLReport(reportFolder, singleTestId);
|
2021-10-29 15:24:08 -08:00
|
|
|
} else {
|
|
|
|
console.log('');
|
|
|
|
console.log('To open last HTML report run:');
|
|
|
|
console.log(colors.cyan(`
|
2021-10-14 20:09:41 -08:00
|
|
|
npx playwright show-report
|
|
|
|
`));
|
2021-09-14 13:55:31 -07:00
|
|
|
}
|
2021-08-05 13:36:47 -07:00
|
|
|
}
|
2021-09-13 20:34:46 -07:00
|
|
|
}
|
2021-08-05 13:36:47 -07:00
|
|
|
|
2021-10-15 07:15:30 -08:00
|
|
|
export function htmlReportFolder(outputFolder?: string): string {
|
|
|
|
if (process.env[`PLAYWRIGHT_HTML_REPORT`])
|
|
|
|
return path.resolve(process.cwd(), process.env[`PLAYWRIGHT_HTML_REPORT`]);
|
|
|
|
if (outputFolder)
|
|
|
|
return outputFolder;
|
|
|
|
return path.resolve(process.cwd(), 'playwright-report');
|
2021-10-14 20:09:41 -08:00
|
|
|
}
|
|
|
|
|
2021-11-01 09:54:53 -07:00
|
|
|
export async function showHTMLReport(reportFolder: string | undefined, testId?: string) {
|
2021-10-14 20:09:41 -08:00
|
|
|
const folder = reportFolder || htmlReportFolder();
|
|
|
|
try {
|
|
|
|
assert(fs.statSync(folder).isDirectory());
|
|
|
|
} catch (e) {
|
|
|
|
console.log(colors.red(`No report found at "${folder}"`));
|
|
|
|
process.exit(1);
|
|
|
|
return;
|
|
|
|
}
|
2021-10-23 10:23:39 -08:00
|
|
|
const server = startHtmlReportServer(folder);
|
2021-11-01 09:54:53 -07:00
|
|
|
let url = await server.start(9323);
|
2021-10-23 10:23:39 -08:00
|
|
|
console.log('');
|
|
|
|
console.log(colors.cyan(` Serving HTML report at ${url}. Press Ctrl+C to quit.`));
|
2021-11-01 09:54:53 -07:00
|
|
|
if (testId)
|
|
|
|
url += `#?testId=${testId}`;
|
2021-10-23 10:23:39 -08:00
|
|
|
open(url);
|
|
|
|
process.on('SIGINT', () => process.exit(0));
|
|
|
|
await new Promise(() => {});
|
|
|
|
}
|
|
|
|
|
|
|
|
export function startHtmlReportServer(folder: string): HttpServer {
|
2021-10-14 20:09:41 -08:00
|
|
|
const server = new HttpServer();
|
|
|
|
server.routePrefix('/', (request, response) => {
|
|
|
|
let relativePath = new URL('http://localhost' + request.url).pathname;
|
2021-10-23 10:23:39 -08:00
|
|
|
if (relativePath.startsWith('/trace/file')) {
|
|
|
|
const url = new URL('http://localhost' + request.url!);
|
|
|
|
try {
|
|
|
|
return server.serveFile(response, url.searchParams.get('path')!);
|
|
|
|
} catch (e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2021-10-14 20:09:41 -08:00
|
|
|
if (relativePath === '/')
|
|
|
|
relativePath = '/index.html';
|
|
|
|
const absolutePath = path.join(folder, ...relativePath.split('/'));
|
|
|
|
return server.serveFile(response, absolutePath);
|
|
|
|
});
|
2021-10-23 10:23:39 -08:00
|
|
|
return server;
|
2021-10-14 20:09:41 -08:00
|
|
|
}
|
|
|
|
|
2021-09-13 20:34:46 -07:00
|
|
|
class HtmlBuilder {
|
|
|
|
private _reportFolder: string;
|
|
|
|
private _tests = new Map<string, JsonTestCase>();
|
2021-10-17 19:58:06 -08:00
|
|
|
private _testPath = new Map<string, string[]>();
|
2021-09-14 16:26:31 -07:00
|
|
|
private _dataFolder: string;
|
2021-10-18 07:03:04 -08:00
|
|
|
private _hasTraces = false;
|
2021-09-13 20:34:46 -07:00
|
|
|
|
2021-10-14 20:09:41 -08:00
|
|
|
constructor(outputDir: string, rootDir: string) {
|
2021-09-13 20:34:46 -07:00
|
|
|
this._reportFolder = path.resolve(process.cwd(), outputDir);
|
2021-09-14 16:26:31 -07:00
|
|
|
this._dataFolder = path.join(this._reportFolder, 'data');
|
2021-10-14 20:09:41 -08:00
|
|
|
}
|
|
|
|
|
2021-11-01 09:54:53 -07:00
|
|
|
build(rawReports: JsonReport[]): { ok: boolean, singleTestId: string | undefined } {
|
2021-09-14 16:26:31 -07:00
|
|
|
fs.mkdirSync(this._dataFolder, { recursive: true });
|
2021-10-13 10:07:29 -08:00
|
|
|
|
2021-10-17 19:58:06 -08:00
|
|
|
const data = new Map<string, { testFile: TestFile, testFileSummary: TestFileSummary }>();
|
2021-09-13 20:34:46 -07:00
|
|
|
for (const projectJson of rawReports) {
|
|
|
|
for (const file of projectJson.suites) {
|
2021-10-18 12:34:02 -08:00
|
|
|
const fileName = file.location!.file;
|
|
|
|
const fileId = file.fileId;
|
2021-10-17 19:58:06 -08:00
|
|
|
let fileEntry = data.get(fileId);
|
|
|
|
if (!fileEntry) {
|
|
|
|
fileEntry = {
|
|
|
|
testFile: { fileId, fileName, tests: [] },
|
|
|
|
testFileSummary: { fileId, fileName, tests: [], stats: emptyStats() },
|
|
|
|
};
|
|
|
|
data.set(fileId, fileEntry);
|
|
|
|
}
|
|
|
|
const { testFile, testFileSummary } = fileEntry;
|
|
|
|
const testEntries: TestEntry[] = [];
|
|
|
|
this._processJsonSuite(file, fileId, projectJson.project.name, [], testEntries);
|
|
|
|
for (const test of testEntries) {
|
|
|
|
testFile.tests.push(test.testCase);
|
|
|
|
testFileSummary.tests.push(test.testCaseSummary);
|
|
|
|
}
|
2021-09-13 20:34:46 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-17 19:58:06 -08:00
|
|
|
let ok = true;
|
|
|
|
for (const [fileId, { testFile, testFileSummary }] of data) {
|
|
|
|
const stats = testFileSummary.stats;
|
|
|
|
for (const test of testFileSummary.tests) {
|
|
|
|
if (test.outcome === 'expected')
|
|
|
|
++stats.expected;
|
|
|
|
if (test.outcome === 'skipped')
|
|
|
|
++stats.skipped;
|
|
|
|
if (test.outcome === 'unexpected')
|
|
|
|
++stats.unexpected;
|
|
|
|
if (test.outcome === 'flaky')
|
|
|
|
++stats.flaky;
|
|
|
|
++stats.total;
|
|
|
|
stats.duration += test.duration;
|
|
|
|
}
|
|
|
|
stats.ok = stats.unexpected + stats.flaky === 0;
|
|
|
|
if (!stats.ok)
|
|
|
|
ok = false;
|
|
|
|
|
|
|
|
testFileSummary.tests.sort((t1, t2) => {
|
|
|
|
const w1 = (t1.outcome === 'unexpected' ? 1000 : 0) + (t1.outcome === 'flaky' ? 1 : 0);
|
|
|
|
const w2 = (t2.outcome === 'unexpected' ? 1000 : 0) + (t2.outcome === 'flaky' ? 1 : 0);
|
|
|
|
if (w2 - w1)
|
|
|
|
return w2 - w1;
|
|
|
|
return t1.location.line - t2.location.line;
|
|
|
|
});
|
2021-08-05 13:36:47 -07:00
|
|
|
|
2021-10-17 19:58:06 -08:00
|
|
|
fs.writeFileSync(path.join(this._dataFolder, fileId + '.json'), JSON.stringify(testFile, undefined, 2));
|
2021-09-14 13:55:31 -07:00
|
|
|
}
|
2021-10-17 19:58:06 -08:00
|
|
|
const htmlReport: HTMLReport = {
|
|
|
|
files: [...data.values()].map(e => e.testFileSummary),
|
2021-10-18 07:03:04 -08:00
|
|
|
projectNames: rawReports.map(r => r.project.name),
|
|
|
|
stats: [...data.values()].reduce((a, e) => addStats(a, e.testFileSummary.stats), emptyStats())
|
2021-08-05 13:36:47 -07:00
|
|
|
};
|
2021-10-17 19:58:06 -08:00
|
|
|
htmlReport.files.sort((f1, f2) => {
|
|
|
|
const w1 = f1.stats.unexpected * 1000 + f1.stats.flaky;
|
|
|
|
const w2 = f2.stats.unexpected * 1000 + f2.stats.flaky;
|
|
|
|
return w2 - w1;
|
|
|
|
});
|
2021-10-18 07:03:04 -08:00
|
|
|
|
2021-10-17 19:58:06 -08:00
|
|
|
fs.writeFileSync(path.join(this._dataFolder, 'report.json'), JSON.stringify(htmlReport, undefined, 2));
|
2021-10-18 07:03:04 -08:00
|
|
|
|
|
|
|
// Copy app.
|
|
|
|
const appFolder = path.join(require.resolve('playwright-core'), '..', 'lib', 'webpack', 'htmlReport');
|
|
|
|
for (const file of fs.readdirSync(appFolder)) {
|
|
|
|
if (file.endsWith('.map'))
|
|
|
|
continue;
|
|
|
|
fs.copyFileSync(path.join(appFolder, file), path.join(this._reportFolder, file));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copy trace viewer.
|
|
|
|
if (this._hasTraces) {
|
|
|
|
const traceViewerFolder = path.join(require.resolve('playwright-core'), '..', 'lib', 'webpack', 'traceViewer');
|
|
|
|
const traceViewerTargetFolder = path.join(this._reportFolder, 'trace');
|
|
|
|
fs.mkdirSync(traceViewerTargetFolder, { recursive: true });
|
|
|
|
for (const file of fs.readdirSync(traceViewerFolder)) {
|
|
|
|
if (file.endsWith('.map'))
|
|
|
|
continue;
|
|
|
|
fs.copyFileSync(path.join(traceViewerFolder, file), path.join(traceViewerTargetFolder, file));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-01 09:54:53 -07:00
|
|
|
let singleTestId: string | undefined;
|
|
|
|
if (htmlReport.stats.total === 1) {
|
|
|
|
const testFile: TestFile = data.values().next().value.testFile;
|
|
|
|
singleTestId = testFile.tests[0].testId;
|
|
|
|
}
|
|
|
|
return { ok, singleTestId };
|
2021-08-05 13:36:47 -07:00
|
|
|
}
|
|
|
|
|
2021-10-17 19:58:06 -08:00
|
|
|
private _processJsonSuite(suite: JsonSuite, fileId: string, projectName: string, path: string[], out: TestEntry[]) {
|
|
|
|
const newPath = [...path, suite.title];
|
|
|
|
suite.suites.map(s => this._processJsonSuite(s, fileId, projectName, newPath, out));
|
2021-11-01 09:53:42 -08:00
|
|
|
suite.tests.forEach(t => out.push(this._createTestEntry(t, projectName, newPath)));
|
2021-10-17 19:58:06 -08:00
|
|
|
}
|
|
|
|
|
2021-11-01 09:53:42 -08:00
|
|
|
private _createTestEntry(test: JsonTestCase, projectName: string, path: string[]): TestEntry {
|
2021-09-13 20:34:46 -07:00
|
|
|
const duration = test.results.reduce((a, r) => a + r.duration, 0);
|
|
|
|
this._tests.set(test.testId, test);
|
2021-10-18 12:34:02 -08:00
|
|
|
const location = test.location;
|
2021-11-01 09:53:42 -08:00
|
|
|
path = [...path.slice(1)];
|
2021-10-17 19:58:06 -08:00
|
|
|
this._testPath.set(test.testId, path);
|
|
|
|
|
2021-08-05 13:36:47 -07:00
|
|
|
return {
|
2021-10-17 19:58:06 -08:00
|
|
|
testCase: {
|
|
|
|
testId: test.testId,
|
|
|
|
title: test.title,
|
|
|
|
projectName,
|
|
|
|
location,
|
|
|
|
duration,
|
|
|
|
outcome: test.outcome,
|
|
|
|
path,
|
|
|
|
results: test.results.map(r => this._createTestResult(r)),
|
|
|
|
ok: test.outcome === 'expected' || test.outcome === 'flaky',
|
|
|
|
},
|
|
|
|
testCaseSummary: {
|
|
|
|
testId: test.testId,
|
|
|
|
title: test.title,
|
|
|
|
projectName,
|
|
|
|
location,
|
|
|
|
duration,
|
|
|
|
outcome: test.outcome,
|
|
|
|
path,
|
|
|
|
ok: test.outcome === 'expected' || test.outcome === 'flaky',
|
|
|
|
},
|
2021-08-05 13:36:47 -07:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-10-15 15:15:06 -08:00
|
|
|
private _createTestResult(result: JsonTestResult): TestResult {
|
|
|
|
let lastAttachment: TestAttachment | undefined;
|
2021-08-05 13:36:47 -07:00
|
|
|
return {
|
|
|
|
duration: result.duration,
|
2021-09-13 20:34:46 -07:00
|
|
|
startTime: result.startTime,
|
|
|
|
retry: result.retry,
|
|
|
|
steps: result.steps.map(s => this._createTestStep(s)),
|
2021-09-14 13:55:31 -07:00
|
|
|
error: result.error,
|
2021-08-05 13:36:47 -07:00
|
|
|
status: result.status,
|
2021-09-14 16:26:31 -07:00
|
|
|
attachments: result.attachments.map(a => {
|
2021-10-18 07:03:04 -08:00
|
|
|
if (a.name === 'trace')
|
|
|
|
this._hasTraces = true;
|
2021-09-14 16:26:31 -07:00
|
|
|
if (a.path) {
|
2021-10-14 14:48:05 -08:00
|
|
|
let fileName = a.path;
|
2021-09-14 16:26:31 -07:00
|
|
|
try {
|
2021-10-14 14:48:05 -08:00
|
|
|
const buffer = fs.readFileSync(a.path);
|
|
|
|
const sha1 = calculateSha1(buffer) + path.extname(a.path);
|
|
|
|
fileName = 'data/' + sha1;
|
|
|
|
fs.writeFileSync(path.join(this._reportFolder, 'data', sha1), buffer);
|
2021-09-14 16:26:31 -07:00
|
|
|
} catch (e) {
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
name: a.name,
|
|
|
|
contentType: a.contentType,
|
|
|
|
path: fileName,
|
|
|
|
body: a.body,
|
|
|
|
};
|
|
|
|
}
|
2021-10-15 15:15:06 -08:00
|
|
|
|
|
|
|
if ((a.name === 'stdout' || a.name === 'stderr') &&
|
|
|
|
a.contentType === 'text/plain' &&
|
|
|
|
lastAttachment &&
|
|
|
|
lastAttachment.name === a.name &&
|
|
|
|
lastAttachment.contentType === a.contentType) {
|
|
|
|
lastAttachment.body += a.body as string;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
lastAttachment = a;
|
2021-09-14 16:26:31 -07:00
|
|
|
return a;
|
2021-10-15 15:15:06 -08:00
|
|
|
}).filter(Boolean) as TestAttachment[]
|
2021-08-05 13:36:47 -07:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-09-13 20:34:46 -07:00
|
|
|
private _createTestStep(step: JsonTestStep): TestStep {
|
2021-08-10 17:06:25 -07:00
|
|
|
return {
|
2021-09-13 20:34:46 -07:00
|
|
|
title: step.title,
|
|
|
|
startTime: step.startTime,
|
|
|
|
duration: step.duration,
|
2021-10-18 21:14:01 -08:00
|
|
|
snippet: step.snippet,
|
2021-09-13 20:34:46 -07:00
|
|
|
steps: step.steps.map(s => this._createTestStep(s)),
|
2021-10-18 21:14:01 -08:00
|
|
|
location: step.location,
|
2021-09-14 13:55:31 -07:00
|
|
|
error: step.error
|
2021-08-10 17:06:25 -07:00
|
|
|
};
|
2021-08-07 15:47:03 -07:00
|
|
|
}
|
2021-08-31 16:34:52 -07:00
|
|
|
}
|
|
|
|
|
2021-09-14 13:55:31 -07:00
|
|
|
const emptyStats = (): Stats => {
|
|
|
|
return {
|
|
|
|
total: 0,
|
|
|
|
expected: 0,
|
|
|
|
unexpected: 0,
|
|
|
|
flaky: 0,
|
|
|
|
skipped: 0,
|
2021-10-17 19:58:06 -08:00
|
|
|
ok: true,
|
|
|
|
duration: 0,
|
2021-09-14 13:55:31 -07:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-10-18 07:03:04 -08:00
|
|
|
const addStats = (stats: Stats, delta: Stats): Stats => {
|
|
|
|
stats.total += delta.total;
|
|
|
|
stats.skipped += delta.skipped;
|
|
|
|
stats.expected += delta.expected;
|
|
|
|
stats.unexpected += delta.unexpected;
|
|
|
|
stats.flaky += delta.flaky;
|
|
|
|
stats.ok = stats.ok && delta.ok;
|
|
|
|
stats.duration += delta.duration;
|
|
|
|
return stats;
|
|
|
|
};
|
|
|
|
|
2021-08-05 13:36:47 -07:00
|
|
|
export default HtmlReporter;
|