MCPcopy
hub / github.com/testing-library/dom-testing-library / getNodeText

Function getNodeText

src/get-node-text.ts:3–14  ·  view source on GitHub ↗
(node: HTMLElement)

Source from the content-addressed store, hash-verified

1import {TEXT_NODE} from './helpers'
2
3function getNodeText(node: HTMLElement): string {
4 if (
5 node.matches('input[type=submit], input[type=button], input[type=reset]')
6 ) {
7 return (node as HTMLInputElement).value
8 }
9
10 return Array.from(node.childNodes)
11 .filter(child => child.nodeType === TEXT_NODE && Boolean(child.textContent))
12 .map(c => c.textContent)
13 .join('')
14}
15
16export {getNodeText}

Callers 5

getSuggestedQueryFunction · 0.90
get-node-text.jsFile · 0.90
queryAllByTextFunction · 0.85
queryAllByTitleFunction · 0.85
queryAllByDisplayValueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected