MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / scanErrors

Function scanErrors

lib/html.js:197–215  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

195
196 // Function to recursively scan for error classes and messages
197 function scanErrors(node) {
198 if (node.attrs) {
199 const classAttr = node.attrs.find(attr => attr.name === 'class')
200 if (classAttr && classAttr.value) {
201 const classNameChunks = classAttr.value.split(' ')
202 const errorClassFound = errorClasses.some(errorClass => classNameChunks.includes(errorClass))
203 if (errorClassFound && node.childNodes) {
204 const errorMessage = sanitizeTextContent(node)
205 errorMessages.push(errorMessage)
206 }
207 }
208 }
209
210 if (node.childNodes) {
211 for (const childNode of node.childNodes) {
212 scanErrors(childNode)
213 }
214 }
215 }
216
217 // Start scanning for error classes and messages from the root element
218 scanErrors(document)

Callers 1

scanForErrorMessagesFunction · 0.85

Calls 4

sanitizeTextContentFunction · 0.85
includesMethod · 0.80
pushMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected