diff --git a/packages/playwright-test/src/cli.ts b/packages/playwright-test/src/cli.ts index 9818ebca82..b0ea525655 100644 --- a/packages/playwright-test/src/cli.ts +++ b/packages/playwright-test/src/cli.ts @@ -170,10 +170,11 @@ async function runTests(args: string[], opts: { [key: string]: any }) { async function listTests(opts: { [key: string]: any }) { const configFile = opts.config ? path.resolve(process.cwd(), opts.config) : process.cwd(); const runner = new Runner({}, { defaultConfig: {} }); - await runner.loadConfigFromFile(configFile); - const report = await runner.listAllTestFiles(opts.project); - process.stdout.write(JSON.stringify(report)); - process.exit(0); + const config = await runner.loadConfigFromFile(configFile); + const report = await runner.listAllTestFiles(config, opts.project); + process.stdout.write(JSON.stringify(report), () => { + process.exit(0); + }); } function forceRegExp(pattern: string): RegExp { diff --git a/packages/playwright-test/src/runner.ts b/packages/playwright-test/src/runner.ts index db6d63a84b..1ee15e3e57 100644 --- a/packages/playwright-test/src/runner.ts +++ b/packages/playwright-test/src/runner.ts @@ -163,9 +163,10 @@ export class Runner { } } - async listAllTestFiles(projectNames: string[] | undefined): Promise { + async listAllTestFiles(config: Config, projectNames: string[] | undefined): Promise { const filesByProject = await this._collectFiles([], projectNames); const report: any = { + testDir: config.testDir, projects: [] }; for (const [project, files] of filesByProject) {