Skip to content

Commit adef765

Browse files
committed
cherry-pick(#22609): chore: fix list-files
1 parent eed6c33 commit adef765

File tree

1 file changed

+15
-31
lines changed

1 file changed

+15
-31
lines changed

packages/playwright-test/src/runner/runner.ts

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,26 @@ export class Runner {
3434
}
3535

3636
async listTestFiles(projectNames: string[] | undefined): Promise<any> {
37+
type ProjectConfigWithFiles = {
38+
name: string;
39+
testDir: string;
40+
use: { testIdAttribute?: string };
41+
files: string[];
42+
};
43+
44+
type ConfigListFilesReport = {
45+
projects: ProjectConfigWithFiles[];
46+
};
47+
3748
const projects = filterProjects(this._config.projects, projectNames);
38-
const report: any = {
49+
const report: ConfigListFilesReport = {
3950
projects: []
4051
};
4152
for (const project of projects) {
4253
report.projects.push({
43-
...sanitizeConfigForJSON(project, new Set()),
54+
name: project.project.name,
55+
testDir: project.project.testDir,
56+
use: { testIdAttribute: project.project.use.testIdAttribute },
4457
files: await collectFilesForProject(project)
4558
});
4659
}
@@ -99,32 +112,3 @@ export class Runner {
99112
return await runUIMode(config);
100113
}
101114
}
102-
103-
function sanitizeConfigForJSON(object: any, visited: Set<any>): any {
104-
const type = typeof object;
105-
if (type === 'function' || type === 'symbol')
106-
return undefined;
107-
if (!object || type !== 'object')
108-
return object;
109-
110-
if (object instanceof RegExp)
111-
return String(object);
112-
if (object instanceof Date)
113-
return object.toISOString();
114-
115-
if (visited.has(object))
116-
return undefined;
117-
visited.add(object);
118-
119-
if (Array.isArray(object))
120-
return object.map(a => sanitizeConfigForJSON(a, visited));
121-
122-
const result: any = {};
123-
const keys = Object.keys(object).slice(0, 100);
124-
for (const key of keys) {
125-
if (key.startsWith('_'))
126-
continue;
127-
result[key] = sanitizeConfigForJSON(object[key], visited);
128-
}
129-
return result;
130-
}

0 commit comments

Comments
 (0)