Include component stack in 'act(...)' warning (#14855)
* add a component stack trace to the act() warning * pass tests * nit
Sunil Pai committed
Feb 14, 2019 at 17:20 UTC
c555c008b6e13004c57784950eb325ed1d917575
2 files changed
+6
-5
packages/react-dom/src/__tests__/ReactTestUtils-test.js
+3
-4
@@ -634,10 +634,9 @@ describe('ReactTestUtils', () => {
634
button.dispatchEvent(new MouseEvent('click', {bubbles: true}));
635
});
636
expect(button.innerHTML).toBe('2');
637
- expect(() => setValueRef(1)).toWarnDev(
638
- ['An update to App inside a test was not wrapped in act(...).'],
639
- {withoutStack: 1},
640
- );
637
+ expect(() => setValueRef(1)).toWarnDev([
638
+ 'An update to App inside a test was not wrapped in act(...).',
639
+ ]);
640
document.body.removeChild(container);
641
});
642
packages/react-reconciler/src/ReactFiberScheduler.js
+3
-1
@@ -1839,8 +1839,10 @@ export function warnIfNotCurrentlyBatchingInDev(fiber: Fiber): void {
1839
'});\n' +
1840
'/* assert on the output */\n\n' +
1841
"This ensures that you're testing the behavior the user would see in the browser." +
1842
- ' Learn more at https://fb.me/react-wrap-tests-with-act',
1842
+ ' Learn more at https://fb.me/react-wrap-tests-with-act' +
1843
+ '%s',
1844
getComponentName(fiber.type),
1845
+ getStackByFiberInDevAndProd(fiber),
1846
);
1847
}
1848
}