(format, ...args)
| 22 | |
| 23 | const patchConsoleMethod = (methodName, logged) => { |
| 24 | const newMethod = function (format, ...args) { |
| 25 | // Ignore uncaught errors reported by jsdom |
| 26 | // and React addendums because they're too noisy. |
| 27 | if (shouldIgnoreConsoleError(format, args)) { |
| 28 | return; |
| 29 | } |
| 30 | |
| 31 | // Ignore certain React warnings causing test failures |
| 32 | if (methodName === 'warn' && shouldIgnoreConsoleWarn(format)) { |
| 33 | return; |
| 34 | } |
| 35 | |
| 36 | // Append Component Stacks. Simulates a framework or DevTools appending them. |
| 37 | if ( |
| 38 | typeof format === 'string' && |
| 39 | (methodName === 'error' || methodName === 'warn') |
| 40 | ) { |
| 41 | const React = require('react'); |
| 42 | |
| 43 | // Ideally we could remove this check, but we have some tests like |
| 44 | // useSyncExternalStoreShared-test that tests against React 17, |
| 45 | // which doesn't have the captureOwnerStack method. |
| 46 | if (React.captureOwnerStack) { |
| 47 | const stack = React.captureOwnerStack(); |
| 48 | if (stack) { |
| 49 | format += '%s'; |
| 50 | args.push(stack); |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | logged.push([format, ...args]); |
| 56 | }; |
| 57 | |
| 58 | console[methodName] = newMethod; |
| 59 |
nothing calls this directly
no test coverage detected