Skip to content

Commit

Permalink
Update manual mock in test
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Jul 11, 2024
1 parent 2c53738 commit ee868f6
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions packages/react-dom/src/__tests__/ReactUpdates-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
};
Expand All @@ -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 () => {
Expand Down

0 comments on commit ee868f6

Please sign in to comment.