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

Function assertSingleNodeFromXPath

tests/_helpers/setup.ts:75–88  ·  view source on GitHub ↗
(xpath: string, context: Node)

Source from the content-addressed store, hash-verified

73}
74
75function assertSingleNodeFromXPath(xpath: string, context: Node) {
76 const node = document.evaluate(
77 xpath,
78 context,
79 undefined,
80 XPathResult.FIRST_ORDERED_NODE_TYPE,
81 ).singleNodeValue
82
83 if (!node) {
84 throw new Error(`invalid XPath: "${xpath}"`)
85 }
86
87 return node
88}
89
90export function setup<Elements extends Element | Element[] = HTMLElement>(
91 ui: string,

Callers 1

renderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected