MCPcopy Create free account
hub / github.com/testing-library/dom-testing-library / getUserCodeFrame

Function getUserCodeFrame

src/get-user-code-frame.js:52–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

50}
51
52function getUserCodeFrame() {
53 // If we couldn't load dependencies, we can't generate the user trace
54 /* istanbul ignore next */
55 if (!readFileSync || !codeFrameColumns) {
56 return ''
57 }
58 const err = new Error()
59 const firstClientCodeFrame = err.stack
60 .split('\n')
61 .slice(1) // Remove first line which has the form "Error: TypeError"
62 .find(frame => !frame.includes('node_modules/')) // Ignore frames from 3rd party libraries
63
64 return getCodeFrame(firstClientCodeFrame)
65}
66
67export {getUserCodeFrame}

Callers 2

logDOMFunction · 0.90

Calls 1

getCodeFrameFunction · 0.85

Tested by

no test coverage detected