Skip to content

Commit 09f2256

Browse files
committed
Update manual mock in test
1 parent c399d9b commit 09f2256

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

packages/react-dom/src/__tests__/ReactUpdates-test.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,12 +1857,14 @@ describe('ReactUpdates', () => {
18571857
}
18581858

18591859
let error = null;
1860-
let stack = null;
1860+
let ownerStack = null;
18611861
let nativeStack = null;
18621862
const originalConsoleError = console.error;
1863-
console.error = (e, s) => {
1863+
console.error = e => {
18641864
error = e;
1865-
stack = s;
1865+
ownerStack = gate(flags => flags.enableOwnerStacks)
1866+
? React.captureOwnerStack()
1867+
: null;
18661868
nativeStack = new Error().stack;
18671869
Scheduler.log('stop');
18681870
};
@@ -1878,12 +1880,11 @@ describe('ReactUpdates', () => {
18781880
expect(error).toContain('Maximum update depth exceeded');
18791881
// The currently executing effect should be on the native stack
18801882
expect(nativeStack).toContain('at myEffect');
1881-
if (!gate(flags => flags.enableOwnerStacks)) {
1882-
// The currently running component's name is not in the owner
1883-
// stack because it's just its JSX callsite.
1884-
expect(stack).toContain('at NonTerminating');
1883+
if (gate(flags => flags.enableOwnerStacks)) {
1884+
expect(ownerStack).toContain('at App');
1885+
} else {
1886+
expect(ownerStack).toBe(null);
18851887
}
1886-
expect(stack).toContain('at App');
18871888
});
18881889

18891890
it('can have nested updates if they do not cross the limit', async () => {

0 commit comments

Comments
 (0)