From a9f9d5515a6f3b748a412bf8fb481e44446638a9 Mon Sep 17 00:00:00 2001 From: Harminder Virk Date: Wed, 22 Nov 2023 10:02:09 +0530 Subject: [PATCH] refactor: do not split --tests filter by comma Otherwise tests title with comma get split into two test filters --- src/config_manager.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/config_manager.ts b/src/config_manager.ts index 99799a6..5d288ee 100644 --- a/src/config_manager.ts +++ b/src/config_manager.ts @@ -51,8 +51,12 @@ export class ConfigManager { * Processes a CLI argument and converts it to an * array of strings */ - #processAsArray(value: string | string[]): string[] { - return Array.isArray(value) ? value : value.split(',').map((item: string) => item.trim()) + #processAsArray(value: string | string[], splitByComma: boolean): string[] { + return Array.isArray(value) + ? value + : splitByComma + ? value.split(',').map((item: string) => item.trim()) + : [value] } /** @@ -63,19 +67,19 @@ export class ConfigManager { const filters: Filters = {} if (this.#cliArgs.tags) { - filters.tags = this.#processAsArray(this.#cliArgs.tags) + filters.tags = this.#processAsArray(this.#cliArgs.tags, true) } if (this.#cliArgs.tests) { - filters.tests = this.#processAsArray(this.#cliArgs.tests) + filters.tests = this.#processAsArray(this.#cliArgs.tests, false) } if (this.#cliArgs.files) { - filters.files = this.#processAsArray(this.#cliArgs.files) + filters.files = this.#processAsArray(this.#cliArgs.files, true) } if (this.#cliArgs.groups) { - filters.groups = this.#processAsArray(this.#cliArgs.groups) + filters.groups = this.#processAsArray(this.#cliArgs.groups, false) } if (this.#cliArgs._ && this.#cliArgs._.length) { - filters.suites = this.#processAsArray(this.#cliArgs._) + filters.suites = this.#processAsArray(this.#cliArgs._, true) } return filters @@ -120,7 +124,7 @@ export class ConfigManager { */ #getCLIReporters(): string[] | undefined { if (this.#cliArgs.reporters) { - return this.#processAsArray(this.#cliArgs.reporters) + return this.#processAsArray(this.#cliArgs.reporters, true) } }