DevTools: Add break-on-warn feature (#19048)

This commit adds a new tab to the Settings modal: Debugging

This new tab has the append component stacks feature and a new one: break on warn

This new feature adds a debugger statement into the console override
This commit is contained in:
Brian Vaughn
2020-05-29 14:34:43 -07:00
committed by GitHub
parent 89edb0eae3
commit 2efe63d99c
19 changed files with 280 additions and 78 deletions
@@ -44,7 +44,10 @@ describe('console', () => {
// Note the Console module only patches once,
// so it's important to patch the test console before injection.
patchConsole();
patchConsole({
appendComponentStack: true,
breakOnWarn: false,
});
const inject = global.__REACT_DEVTOOLS_GLOBAL_HOOK__.inject;
global.__REACT_DEVTOOLS_GLOBAL_HOOK__.inject = internals => {
@@ -79,7 +82,10 @@ describe('console', () => {
it('should only patch the console once', () => {
const {error, warn} = fakeConsole;
patchConsole();
patchConsole({
appendComponentStack: true,
breakOnWarn: false,
});
expect(fakeConsole.error).toBe(error);
expect(fakeConsole.warn).toBe(warn);
@@ -330,7 +336,10 @@ describe('console', () => {
expect(mockError.mock.calls[0]).toHaveLength(1);
expect(mockError.mock.calls[0][0]).toBe('error');
patchConsole();
patchConsole({
appendComponentStack: true,
breakOnWarn: false,
});
act(() => ReactDOM.render(<Child />, document.createElement('div')));
expect(mockWarn).toHaveBeenCalledTimes(2);