MCPcopy Create free account
hub / github.com/testing-library/user-event / printTree

Function printTree

src/utils/pointer/cssPointerEvents.ts:97–119  ·  view source on GitHub ↗
(tree: Element[])

Source from the content-addressed store, hash-verified

95}
96
97function printTree(tree: Element[]) {
98 return tree
99 .reverse()
100 .map((el, i) =>
101 [
102 ''.padEnd(i),
103 el.tagName,
104 el.id && `#${el.id}`,
105 el.hasAttribute('data-testid') &&
106 `(testId=${el.getAttribute('data-testid')})`,
107 getLabelDescr(el),
108 tree.length > 1 &&
109 i === 0 &&
110 ' <-- This element declared `pointer-events: none`',
111 tree.length > 1 &&
112 i === tree.length - 1 &&
113 ' <-- Asserted pointer events here',
114 ]
115 .filter(Boolean)
116 .join(''),
117 )
118 .join('\n')
119}
120
121function getLabelDescr(element: Element) {
122 let label: string | undefined | null

Callers 1

assertPointerEventsFunction · 0.85

Calls 1

getLabelDescrFunction · 0.85

Tested by

no test coverage detected