From e94044d7c61c27ecddfa1d2e1c4efa6b41c8c3a8 Mon Sep 17 00:00:00 2001 From: gtmnayan <50981692+gtm-nayan@users.noreply.github.com> Date: Tue, 15 Aug 2023 19:34:02 +0545 Subject: [PATCH] perf(dot-renderer): speed up getTests (#3923) --- packages/runner/src/utils/tasks.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/runner/src/utils/tasks.ts b/packages/runner/src/utils/tasks.ts index e80fd52343d3..40464ce8b067 100644 --- a/packages/runner/src/utils/tasks.ts +++ b/packages/runner/src/utils/tasks.ts @@ -6,7 +6,22 @@ function isAtomTest(s: Task): s is Test | TaskCustom { } export function getTests(suite: Arrayable): (Test | TaskCustom)[] { - return toArray(suite).flatMap(s => isAtomTest(s) ? [s] : s.tasks.flatMap(c => isAtomTest(c) ? [c] : getTests(c))) + const tests: (Test | TaskCustom)[] = [] + const suite_arr = toArray(suite) + for (const s of suite_arr) { + if (isAtomTest(s)) { + tests.push(s) + } + else { + for (const task of s.tasks) { + if (isAtomTest(task)) + tests.push(task) + else + tests.push(...getTests(task)) + } + } + } + return tests } export function getTasks(tasks: Arrayable = []): Task[] {