Address comments
This commit is contained in:
parent
b276c0ad47
commit
0ac8fc24f9
|
|
@ -341,20 +341,12 @@ export class TeleReporterReceiver {
|
||||||
parent._addSuite(targetSuite);
|
parent._addSuite(targetSuite);
|
||||||
}
|
}
|
||||||
targetSuite.location = this._absoluteLocation(jsonSuite.location);
|
targetSuite.location = this._absoluteLocation(jsonSuite.location);
|
||||||
if (jsonSuite.entries) {
|
jsonSuite.entries.forEach(e => {
|
||||||
jsonSuite.entries.forEach(e => {
|
if ('testId' in e)
|
||||||
if ('testId' in e)
|
this._mergeTestInto(e, targetSuite!);
|
||||||
this._mergeTestInto(e, targetSuite!);
|
else
|
||||||
else
|
this._mergeSuiteInto(e, targetSuite!);
|
||||||
this._mergeSuiteInto(e, targetSuite!);
|
});
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// before 1.44
|
|
||||||
for (const jsonChildSuite of jsonSuite.suites!)
|
|
||||||
this._mergeSuiteInto(jsonChildSuite, targetSuite);
|
|
||||||
for (const jsonTest of jsonSuite.tests!)
|
|
||||||
this._mergeTestInto(jsonTest, targetSuite);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private _mergeTestInto(jsonTest: JsonTestCase, parent: TeleSuite) {
|
private _mergeTestInto(jsonTest: JsonTestCase, parent: TeleSuite) {
|
||||||
|
|
@ -431,7 +423,7 @@ export class TeleSuite implements reporterTypes.Suite {
|
||||||
allTests(): reporterTypes.TestCase[] {
|
allTests(): reporterTypes.TestCase[] {
|
||||||
const result: reporterTypes.TestCase[] = [];
|
const result: reporterTypes.TestCase[] = [];
|
||||||
const visit = (suite: reporterTypes.Suite) => {
|
const visit = (suite: reporterTypes.Suite) => {
|
||||||
for (const entry of [...suite.suites, ...suite.tests]) {
|
for (const entry of suite.entries()) {
|
||||||
if (entry.type === 'test')
|
if (entry.type === 'test')
|
||||||
result.push(entry);
|
result.push(entry);
|
||||||
else
|
else
|
||||||
|
|
@ -457,13 +449,11 @@ export class TeleSuite implements reporterTypes.Suite {
|
||||||
_addTest(test: TeleTestCase) {
|
_addTest(test: TeleTestCase) {
|
||||||
test.parent = this;
|
test.parent = this;
|
||||||
this._entries.push(test);
|
this._entries.push(test);
|
||||||
this.tests.push(test);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_addSuite(suite: TeleSuite) {
|
_addSuite(suite: TeleSuite) {
|
||||||
suite.parent = this;
|
suite.parent = this;
|
||||||
this._entries.push(suite);
|
this._entries.push(suite);
|
||||||
this.suites.push(suite);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -538,16 +538,13 @@ class BlobModernizer {
|
||||||
_modernize_1_to_2(events: JsonEvent[]): JsonEvent[] {
|
_modernize_1_to_2(events: JsonEvent[]): JsonEvent[] {
|
||||||
return events.map(event => {
|
return events.map(event => {
|
||||||
if (event.method === 'onProject') {
|
if (event.method === 'onProject') {
|
||||||
const modernizeSuite = (suite: blobV1.JsonSuite) => {
|
const modernizeSuite = (suite: blobV1.JsonSuite): JsonSuite => {
|
||||||
for (const child of suite.suites)
|
const newSuites = suite.suites.map(modernizeSuite);
|
||||||
modernizeSuite(child);
|
const { suites, tests, ...remainder } = suite;
|
||||||
(suite as any).entries = [...suite.suites, ...suite.tests];
|
return { entries: [...newSuites, ...tests], ...remainder };
|
||||||
(suite as any).suites = undefined;
|
|
||||||
(suite as any).tests = undefined;
|
|
||||||
};
|
};
|
||||||
const project = event.params.project as blobV1.JsonProject;
|
const project = event.params.project;
|
||||||
for (const suite of project.suites)
|
project.suites = project.suites.map(modernizeSuite);
|
||||||
modernizeSuite(suite);
|
|
||||||
}
|
}
|
||||||
return event;
|
return event;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
6
packages/playwright/types/testReporter.d.ts
vendored
6
packages/playwright/types/testReporter.d.ts
vendored
|
|
@ -41,8 +41,8 @@ export type { FullConfig, TestStatus, FullProject } from './test';
|
||||||
*/
|
*/
|
||||||
export interface Suite {
|
export interface Suite {
|
||||||
/**
|
/**
|
||||||
* Returns type of the suite. The Suites form the following hierarchy: `root` -> `project` -> `file` -> `describe` ->
|
* Returns the type of the suite. The Suites form the following hierarchy: `root` -> `project` -> `file` -> `describe`
|
||||||
* ...`describe` -> `test`.
|
* -> ...`describe` -> `test`.
|
||||||
*/
|
*/
|
||||||
type: 'root' | 'project' | 'file' | 'describe';
|
type: 'root' | 'project' | 'file' | 'describe';
|
||||||
/**
|
/**
|
||||||
|
|
@ -56,7 +56,7 @@ export interface Suite {
|
||||||
allTests(): Array<TestCase>;
|
allTests(): Array<TestCase>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test cases and suites defined directly in this suite. The elements returned in their declaration order. You can
|
* Test cases and suites defined directly in this suite. The elements are returned in their declaration order. You can
|
||||||
* discriminate between different entry types using
|
* discriminate between different entry types using
|
||||||
* [testCase.type](https://playwright.dev/docs/api/class-testcase#test-case-type) and
|
* [testCase.type](https://playwright.dev/docs/api/class-testcase#test-case-type) and
|
||||||
* [suite.type](https://playwright.dev/docs/api/class-suite#suite-type).
|
* [suite.type](https://playwright.dev/docs/api/class-suite#suite-type).
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue