Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: fix list-files (#22609)

Pavel Feldman5120e7d541b7
diff --git a/packages/playwright-test/src/runner/runner.ts b/packages/playwright-test/src/runner/runner.ts
index 8c59ad4482..a8647eae27 100644
--- a/packages/playwright-test/src/runner/runner.ts
+++ b/packages/playwright-test/src/runner/runner.ts
@@ -34,13 +34,26 @@ export class Runner {
}
async listTestFiles(projectNames: string[] | undefined): Promise<any> {
+ type ProjectConfigWithFiles = {
+ name: string;
+ testDir: string;
+ use: { testIdAttribute?: string };
+ files: string[];
+ };
+
+ type ConfigListFilesReport = {
+ projects: ProjectConfigWithFiles[];
+ };
+
const projects = filterProjects(this._config.projects, projectNames);
- const report: any = {
+ const report: ConfigListFilesReport = {
projects: []
};
for (const project of projects) {
report.projects.push({
- ...sanitizeConfigForJSON(project, new Set()),
+ name: project.project.name,
+ testDir: project.project.testDir,
+ use: { testIdAttribute: project.project.use.testIdAttribute },
files: await collectFilesForProject(project)
});
}
@@ -99,32 +112,3 @@ export class Runner {
return await runUIMode(config);
}
}
-
-function sanitizeConfigForJSON(object: any, visited: Set<any>): any {
- const type = typeof object;
- if (type === 'function' || type === 'symbol')
- return undefined;
- if (!object || type !== 'object')
- return object;
-
- if (object instanceof RegExp)
- return String(object);
- if (object instanceof Date)
- return object.toISOString();
-
- if (visited.has(object))
- return undefined;
- visited.add(object);
-
- if (Array.isArray(object))
- return object.map(a => sanitizeConfigForJSON(a, visited));
-
- const result: any = {};
- const keys = Object.keys(object).slice(0, 100);
- for (const key of keys) {
- if (key.startsWith('_'))
- continue;
- result[key] = sanitizeConfigForJSON(object[key], visited);
- }
- return result;
-}