chore: cleanup hooks notion from raw/html reporters (#12610)

This commit is contained in:
Dmitry Gozman 2022-03-08 19:08:31 -08:00 committed by GitHub
parent e895bc2751
commit 4a768294b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 18 deletions

View file

@ -72,7 +72,7 @@ const TestCaseViewLoader: React.FC<{
if (!fileId) if (!fileId)
return; return;
const file = await report.entry(`${fileId}.json`) as TestFile; const file = await report.entry(`${fileId}.json`) as TestFile;
for (const t of [...file.tests, ...file.hooks]) { for (const t of file.tests) {
if (t.testId === testId) { if (t.testId === testId) {
setTest(t); setTest(t);
break; break;

View file

@ -38,7 +38,7 @@ export const TestFileView: React.FC<{
<span style={{ float: 'right' }}>{msToString(file.stats.duration)}</span> <span style={{ float: 'right' }}>{msToString(file.stats.duration)}</span>
{file.fileName} {file.fileName}
</span>}> </span>}>
{[...file.tests, ...file.hooks].filter(t => filter.matches(t)).map(test => {file.tests.filter(t => filter.matches(t)).map(test =>
<div key={`test-${test.testId}`} className={'test-file-test test-file-test-outcome-' + test.outcome}> <div key={`test-${test.testId}`} className={'test-file-test test-file-test-outcome-' + test.outcome}>
<span style={{ float: 'right' }}>{msToString(test.duration)}</span> <span style={{ float: 'right' }}>{msToString(test.duration)}</span>
{report.projectNames.length > 1 && !!test.projectName && {report.projectNames.length > 1 && !!test.projectName &&

View file

@ -53,14 +53,12 @@ export type TestFile = {
fileId: string; fileId: string;
fileName: string; fileName: string;
tests: TestCase[]; tests: TestCase[];
hooks: TestCase[];
}; };
export type TestFileSummary = { export type TestFileSummary = {
fileId: string; fileId: string;
fileName: string; fileName: string;
tests: TestCaseSummary[]; tests: TestCaseSummary[];
hooks: TestCaseSummary[];
stats: Stats; stats: Stats;
}; };
@ -240,23 +238,18 @@ class HtmlBuilder {
let fileEntry = data.get(fileId); let fileEntry = data.get(fileId);
if (!fileEntry) { if (!fileEntry) {
fileEntry = { fileEntry = {
testFile: { fileId, fileName, tests: [], hooks: [] }, testFile: { fileId, fileName, tests: [] },
testFileSummary: { fileId, fileName, tests: [], hooks: [], stats: emptyStats() }, testFileSummary: { fileId, fileName, tests: [], stats: emptyStats() },
}; };
data.set(fileId, fileEntry); data.set(fileId, fileEntry);
} }
const { testFile, testFileSummary } = fileEntry; const { testFile, testFileSummary } = fileEntry;
const testEntries: TestEntry[] = []; const testEntries: TestEntry[] = [];
const hookEntries: TestEntry[] = []; this._processJsonSuite(file, fileId, projectJson.project.name, [], testEntries);
this._processJsonSuite(file, fileId, projectJson.project.name, [], testEntries, hookEntries);
for (const test of testEntries) { for (const test of testEntries) {
testFile.tests.push(test.testCase); testFile.tests.push(test.testCase);
testFileSummary.tests.push(test.testCaseSummary); testFileSummary.tests.push(test.testCaseSummary);
} }
for (const hook of hookEntries) {
testFile.hooks.push(hook.testCase);
testFileSummary.hooks.push(hook.testCaseSummary);
}
} }
} }
@ -287,7 +280,6 @@ class HtmlBuilder {
return t1.location.line - t2.location.line; return t1.location.line - t2.location.line;
}; };
testFileSummary.tests.sort(testCaseSummaryComparator); testFileSummary.tests.sort(testCaseSummaryComparator);
testFileSummary.hooks.sort(testCaseSummaryComparator);
this._addDataFile(fileId + '.json', testFile); this._addDataFile(fileId + '.json', testFile);
} }
@ -345,11 +337,10 @@ class HtmlBuilder {
this._dataZipFile.addBuffer(Buffer.from(JSON.stringify(data)), fileName); this._dataZipFile.addBuffer(Buffer.from(JSON.stringify(data)), fileName);
} }
private _processJsonSuite(suite: JsonSuite, fileId: string, projectName: string, path: string[], outTests: TestEntry[], outHooks: TestEntry[]) { private _processJsonSuite(suite: JsonSuite, fileId: string, projectName: string, path: string[], outTests: TestEntry[]) {
const newPath = [...path, suite.title]; const newPath = [...path, suite.title];
suite.suites.map(s => this._processJsonSuite(s, fileId, projectName, newPath, outTests, outHooks)); suite.suites.map(s => this._processJsonSuite(s, fileId, projectName, newPath, outTests));
suite.tests.forEach(t => outTests.push(this._createTestEntry(t, projectName, newPath))); suite.tests.forEach(t => outTests.push(this._createTestEntry(t, projectName, newPath)));
suite.hooks.forEach(t => outHooks.push(this._createTestEntry(t, projectName, newPath)));
} }
private _createTestEntry(test: JsonTestCase, projectName: string, path: string[]): TestEntry { private _createTestEntry(test: JsonTestCase, projectName: string, path: string[]): TestEntry {

View file

@ -54,7 +54,6 @@ export type JsonSuite = {
location?: JsonLocation; location?: JsonLocation;
suites: JsonSuite[]; suites: JsonSuite[];
tests: JsonTestCase[]; tests: JsonTestCase[];
hooks: JsonTestCase[];
}; };
export type JsonTestCase = { export type JsonTestCase = {
@ -195,7 +194,6 @@ class RawReporter {
location, location,
suites: suite.suites.map(s => this._serializeSuite(s, fileId)), suites: suite.suites.map(s => this._serializeSuite(s, fileId)),
tests: suite.tests.map(t => this._serializeTest(t, fileId)), tests: suite.tests.map(t => this._serializeTest(t, fileId)),
hooks: [],
}; };
} }