From 4a768294b4bb6297d7e7420981902e8c1d1e7a50 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Tue, 8 Mar 2022 19:08:31 -0800 Subject: [PATCH] chore: cleanup hooks notion from raw/html reporters (#12610) --- packages/html-reporter/src/reportView.tsx | 2 +- packages/html-reporter/src/testFileView.tsx | 2 +- .../playwright-test/src/reporters/html.ts | 19 +++++-------------- packages/playwright-test/src/reporters/raw.ts | 2 -- 4 files changed, 7 insertions(+), 18 deletions(-) diff --git a/packages/html-reporter/src/reportView.tsx b/packages/html-reporter/src/reportView.tsx index 24b5cfe036..f7bc5d079b 100644 --- a/packages/html-reporter/src/reportView.tsx +++ b/packages/html-reporter/src/reportView.tsx @@ -72,7 +72,7 @@ const TestCaseViewLoader: React.FC<{ if (!fileId) return; 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) { setTest(t); break; diff --git a/packages/html-reporter/src/testFileView.tsx b/packages/html-reporter/src/testFileView.tsx index cf87210903..b969a52deb 100644 --- a/packages/html-reporter/src/testFileView.tsx +++ b/packages/html-reporter/src/testFileView.tsx @@ -38,7 +38,7 @@ export const TestFileView: React.FC<{ {msToString(file.stats.duration)} {file.fileName} }> - {[...file.tests, ...file.hooks].filter(t => filter.matches(t)).map(test => + {file.tests.filter(t => filter.matches(t)).map(test =>
{msToString(test.duration)} {report.projectNames.length > 1 && !!test.projectName && diff --git a/packages/playwright-test/src/reporters/html.ts b/packages/playwright-test/src/reporters/html.ts index 095b3d92a2..0edf1917bc 100644 --- a/packages/playwright-test/src/reporters/html.ts +++ b/packages/playwright-test/src/reporters/html.ts @@ -53,14 +53,12 @@ export type TestFile = { fileId: string; fileName: string; tests: TestCase[]; - hooks: TestCase[]; }; export type TestFileSummary = { fileId: string; fileName: string; tests: TestCaseSummary[]; - hooks: TestCaseSummary[]; stats: Stats; }; @@ -240,23 +238,18 @@ class HtmlBuilder { let fileEntry = data.get(fileId); if (!fileEntry) { fileEntry = { - testFile: { fileId, fileName, tests: [], hooks: [] }, - testFileSummary: { fileId, fileName, tests: [], hooks: [], stats: emptyStats() }, + testFile: { fileId, fileName, tests: [] }, + testFileSummary: { fileId, fileName, tests: [], stats: emptyStats() }, }; data.set(fileId, fileEntry); } const { testFile, testFileSummary } = fileEntry; const testEntries: TestEntry[] = []; - const hookEntries: TestEntry[] = []; - this._processJsonSuite(file, fileId, projectJson.project.name, [], testEntries, hookEntries); + this._processJsonSuite(file, fileId, projectJson.project.name, [], testEntries); for (const test of testEntries) { testFile.tests.push(test.testCase); 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; }; testFileSummary.tests.sort(testCaseSummaryComparator); - testFileSummary.hooks.sort(testCaseSummaryComparator); this._addDataFile(fileId + '.json', testFile); } @@ -345,11 +337,10 @@ class HtmlBuilder { 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]; - 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.hooks.forEach(t => outHooks.push(this._createTestEntry(t, projectName, newPath))); } private _createTestEntry(test: JsonTestCase, projectName: string, path: string[]): TestEntry { diff --git a/packages/playwright-test/src/reporters/raw.ts b/packages/playwright-test/src/reporters/raw.ts index 9cb155c12d..0a48354112 100644 --- a/packages/playwright-test/src/reporters/raw.ts +++ b/packages/playwright-test/src/reporters/raw.ts @@ -54,7 +54,6 @@ export type JsonSuite = { location?: JsonLocation; suites: JsonSuite[]; tests: JsonTestCase[]; - hooks: JsonTestCase[]; }; export type JsonTestCase = { @@ -195,7 +194,6 @@ class RawReporter { location, suites: suite.suites.map(s => this._serializeSuite(s, fileId)), tests: suite.tests.map(t => this._serializeTest(t, fileId)), - hooks: [], }; }