From ee868f6d91ca0aa95008572be3770dea5222caa0 Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Wed, 10 Jul 2024 15:52:21 -0400 Subject: [PATCH] Update manual mock in test --- .../src/__tests__/ReactUpdates-test.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/react-dom/src/__tests__/ReactUpdates-test.js b/packages/react-dom/src/__tests__/ReactUpdates-test.js index 1d71c71476744..4916a7212937d 100644 --- a/packages/react-dom/src/__tests__/ReactUpdates-test.js +++ b/packages/react-dom/src/__tests__/ReactUpdates-test.js @@ -1857,12 +1857,14 @@ describe('ReactUpdates', () => { } let error = null; - let stack = null; + let ownerStack = null; let nativeStack = null; const originalConsoleError = console.error; - console.error = (e, s) => { + console.error = e => { error = e; - stack = s; + ownerStack = gate(flags => flags.enableOwnerStacks) + ? React.captureOwnerStack() + : null; nativeStack = new Error().stack; Scheduler.log('stop'); }; @@ -1878,12 +1880,11 @@ describe('ReactUpdates', () => { expect(error).toContain('Maximum update depth exceeded'); // The currently executing effect should be on the native stack expect(nativeStack).toContain('at myEffect'); - if (!gate(flags => flags.enableOwnerStacks)) { - // The currently running component's name is not in the owner - // stack because it's just its JSX callsite. - expect(stack).toContain('at NonTerminating'); + if (gate(flags => flags.enableOwnerStacks)) { + expect(ownerStack).toContain('at App'); + } else { + expect(ownerStack).toBe(null); } - expect(stack).toContain('at App'); }); it('can have nested updates if they do not cross the limit', async () => {