From 254a50b9f53bcc982d5f0e2896008993300f5633 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Mon, 24 Apr 2023 14:57:07 -0700 Subject: [PATCH] chore: fix list-files --- packages/playwright-test/src/runner/runner.ts | 46 ++++++------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/packages/playwright-test/src/runner/runner.ts b/packages/playwright-test/src/runner/runner.ts index 8c59ad448277f..a8647eae273d6 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 { + 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 { - 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; -}