Skip to content

Commit e94044d

Browse files
authored
perf(dot-renderer): speed up getTests (#3923)
1 parent 1c08d5d commit e94044d

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

packages/runner/src/utils/tasks.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,22 @@ function isAtomTest(s: Task): s is Test | TaskCustom {
66
}
77

88
export function getTests(suite: Arrayable<Task>): (Test | TaskCustom)[] {
9-
return toArray(suite).flatMap(s => isAtomTest(s) ? [s] : s.tasks.flatMap(c => isAtomTest(c) ? [c] : getTests(c)))
9+
const tests: (Test | TaskCustom)[] = []
10+
const suite_arr = toArray(suite)
11+
for (const s of suite_arr) {
12+
if (isAtomTest(s)) {
13+
tests.push(s)
14+
}
15+
else {
16+
for (const task of s.tasks) {
17+
if (isAtomTest(task))
18+
tests.push(task)
19+
else
20+
tests.push(...getTests(task))
21+
}
22+
}
23+
}
24+
return tests
1025
}
1126

1227
export function getTasks(tasks: Arrayable<Task> = []): Task[] {

0 commit comments

Comments
 (0)