patchConsoleMethod() — react Function Reference
Architecture documentation for the patchConsoleMethod() function in consoleMock.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 3c5e3b88_b4d6_1d09_2f08_eec4c3a52d52["patchConsoleMethod()"] 9565063b_3ea2_9cbf_86d6_3ee1e66bf4cc["consoleMock.js"] 3c5e3b88_b4d6_1d09_2f08_eec4c3a52d52 -->|defined in| 9565063b_3ea2_9cbf_86d6_3ee1e66bf4cc d20ba1b0_60b0_96ce_d960_536391cbe776["patchConsoleMethods()"] d20ba1b0_60b0_96ce_d960_536391cbe776 -->|calls| 3c5e3b88_b4d6_1d09_2f08_eec4c3a52d52 style 3c5e3b88_b4d6_1d09_2f08_eec4c3a52d52 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/internal-test-utils/consoleMock.js lines 23–61
const patchConsoleMethod = (methodName, logged) => {
const newMethod = function (format, ...args) {
// Ignore uncaught errors reported by jsdom
// and React addendums because they're too noisy.
if (shouldIgnoreConsoleError(format, args)) {
return;
}
// Ignore certain React warnings causing test failures
if (methodName === 'warn' && shouldIgnoreConsoleWarn(format)) {
return;
}
// Append Component Stacks. Simulates a framework or DevTools appending them.
if (
typeof format === 'string' &&
(methodName === 'error' || methodName === 'warn')
) {
const React = require('react');
// Ideally we could remove this check, but we have some tests like
// useSyncExternalStoreShared-test that tests against React 17,
// which doesn't have the captureOwnerStack method.
if (React.captureOwnerStack) {
const stack = React.captureOwnerStack();
if (stack) {
format += '%s';
args.push(stack);
}
}
}
logged.push([format, ...args]);
};
console[methodName] = newMethod;
return newMethod;
};
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does patchConsoleMethod() do?
patchConsoleMethod() is a function in the react codebase, defined in packages/internal-test-utils/consoleMock.js.
Where is patchConsoleMethod() defined?
patchConsoleMethod() is defined in packages/internal-test-utils/consoleMock.js at line 23.
What calls patchConsoleMethod()?
patchConsoleMethod() is called by 1 function(s): patchConsoleMethods.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free