MCPcopy
hub / github.com/facebook/react / shouldIgnoreConsoleError

Function shouldIgnoreConsoleError

fixtures/legacy-jsx-runtimes/setupTests.js:11–39  ·  view source on GitHub ↗
(format, args)

Source from the content-addressed store, hash-verified

9const util = require('util');
10
11function shouldIgnoreConsoleError(format, args) {
12 if (process.env.NODE_ENV !== 'production') {
13 if (typeof format === 'string') {
14 if (format.indexOf('Error: Uncaught [') === 0) {
15 // This looks like an uncaught error from invokeGuardedCallback() wrapper
16 // in development that is reported by jsdom. Ignore because it's noisy.
17 return true;
18 }
19 if (format.indexOf('The above error occurred') === 0) {
20 // This looks like an error addendum from ReactFiberErrorLogger.
21 // Ignore it too.
22 return true;
23 }
24 }
25 } else {
26 if (
27 format != null &&
28 typeof format.message === 'string' &&
29 typeof format.stack === 'string' &&
30 args.length === 0
31 ) {
32 // In production, ReactFiberErrorLogger logs error objects directly.
33 // They are noisy too so we'll try to ignore them.
34 return true;
35 }
36 }
37 // Looks legit
38 return false;
39}
40
41function normalizeCodeLocInfo(str) {
42 if (typeof str !== 'string') {

Callers 4

newMethodFunction · 0.85
createLogAssertionFunction · 0.85
expectErrorsFunction · 0.85
consoleSpyFunction · 0.85

Calls

no outgoing calls

Tested by 1

expectErrorsFunction · 0.68