Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: cleanup hooks notion from raw/html reporters (#12610)
Dmitry Gozman4a768294b4bb
diff --git a/packages/html-reporter/src/reportView.tsx b/packages/html-reporter/src/reportView.tsxindex 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.tsxindex 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<{<span style={{ float: 'right' }}>{msToString(file.stats.duration)}</span>{file.fileName}</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}><span style={{ float: 'right' }}>{msToString(test.duration)}</span>{report.projectNames.length > 1 && !!test.projectName &&diff --git a/packages/playwright-test/src/reporters/html.ts b/packages/playwright-test/src/reporters/html.tsindex 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.tsindex 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: [],};}