MCPcopy Create free account
hub / github.com/testing-library/react-testing-library / normalizeCodeLocInfo

Function normalizeCodeLocInfo

tests/toWarnDev.js:35–50  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

33const shouldIgnoreConsoleError = require('./shouldIgnoreConsoleError')
34
35function normalizeCodeLocInfo(str) {
36 if (typeof str !== 'string') {
37 return str
38 }
39 // This special case exists only for the special source location in
40 // ReactElementValidator. That will go away if we remove source locations.
41 str = str.replace(/Check your code at .+?:\d+/g, 'Check your code at **')
42 // V8 format:
43 // at Component (/path/filename.js:123:45)
44 // React format:
45 // in Component (at filename.js:123)
46 // eslint-disable-next-line prefer-arrow-callback
47 return str.replace(/\n +(?:at|in) ([\S]+)[^\n]*/g, function (m, name) {
48 return '\n in ' + name + ' (at **)'
49 })
50}
51
52const createMatcherFor = (consoleMethod, matcherName) =>
53 function matcher(callback, expectedMessages, options = {}) {

Callers 1

consoleSpyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…