mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
chore: cleanup hooks notion from raw/html reporters (#12610)
This commit is contained in:
parent
e895bc2751
commit
4a768294b4
@ -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;
|
||||
|
||||
@ -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 &&
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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: [],
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user