MCPcopy
hub / github.com/vitest-dev/vitest / walkCollection

Function walkCollection

test/test-utils/index.ts:633–654  ·  view source on GitHub ↗
(collection: TestCollection)

Source from the content-addressed store, hash-verified

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

Callers 1

buildTestTreeFunction · 0.85

Calls 1

resultMethod · 0.80

Tested by

no test coverage detected