| 631 | type TestTree = Record<string, any> |
| 632 | |
| 633 | function walkCollection(collection: TestCollection): TestTree { |
| 634 | const node: TestTree = {} |
| 635 | |
| 636 | for (const child of collection) { |
| 637 | if (child.type === 'suite') { |
| 638 | // Recursively walk suite children |
| 639 | const suiteChildren = walkCollection(child.children) |
| 640 | node[child.name] = onTestSuite ? onTestSuite(child, suiteChildren) : suiteChildren |
| 641 | } |
| 642 | else if (child.type === 'test') { |
| 643 | const result = child.result() |
| 644 | if (onTestCase) { |
| 645 | node[child.name] = onTestCase(child) |
| 646 | } |
| 647 | else { |
| 648 | node[child.name] = result.state |
| 649 | } |
| 650 | } |
| 651 | } |
| 652 | |
| 653 | return node |
| 654 | } |
| 655 | |
| 656 | const tree: TestTree = {} |
| 657 | |