Skip to content

Commit

Permalink
perf(dot-renderer): speed up getTests (#3923)
Browse files Browse the repository at this point in the history
  • Loading branch information
gtm-nayan committed Aug 15, 2023
1 parent 1c08d5d commit e94044d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion packages/runner/src/utils/tasks.ts
Expand Up @@ -6,7 +6,22 @@ function isAtomTest(s: Task): s is Test | TaskCustom {
}

export function getTests(suite: Arrayable<Task>): (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> = []): Task[] {
Expand Down

0 comments on commit e94044d

Please sign in to comment.