From f92ad70942bdfdbab1dc378988cd3260439fa4c6 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Fri, 15 Mar 2024 16:25:26 +0100 Subject: [PATCH] fix: error handling on list-files (#441) --- src/playwrightTest.ts | 8 ++++++-- src/testModel.ts | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/playwrightTest.ts b/src/playwrightTest.ts index f6a0d1b4a..11dd6ed65 100644 --- a/src/playwrightTest.ts +++ b/src/playwrightTest.ts @@ -109,8 +109,12 @@ export class PlaywrightTest { this._log(`${escapeRegex(path.relative(config.workspaceFolder, configFolder))}> playwright list-files -c ${configFile}`); } const output = await this._runNode(allArgs, configFolder); - const result = JSON.parse(output) as ConfigListFilesReport; - return result; + const result = JSON.parse(output) as Partial; + return { + // list-files does not return `projects: []` if there is an error. + projects: [], + ...result, + }; } private async _listFilesServer(config: TestConfig): Promise { diff --git a/src/testModel.ts b/src/testModel.ts index e5788d5ba..07d353383 100644 --- a/src/testModel.ts +++ b/src/testModel.ts @@ -396,7 +396,8 @@ export class TestModelCollection extends DisposableBase { firstProject = false; } } else { - model.projects()[0].isEnabled = true; + if (model.projects().length) + model.projects()[0].isEnabled = true; } }