From ff958488e3f95ea7547a7b29f668d023b322e742 Mon Sep 17 00:00:00 2001 From: Sunil Pai Date: Thu, 14 Feb 2019 16:50:34 +0000 Subject: [PATCH 1/3] add a component stack trace to the act() warning --- packages/react-reconciler/src/ReactFiberScheduler.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react-reconciler/src/ReactFiberScheduler.js b/packages/react-reconciler/src/ReactFiberScheduler.js index de4fa2b0a053e..f4b081e69e36e 100644 --- a/packages/react-reconciler/src/ReactFiberScheduler.js +++ b/packages/react-reconciler/src/ReactFiberScheduler.js @@ -1815,8 +1815,9 @@ export function warnIfNotCurrentlyBatchingInDev(fiber: Fiber): void { '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see in the browser." + - ' Learn more at https://fb.me/react-wrap-tests-with-act', + ' Learn more at https://fb.me/react-wrap-tests-with-act\n%s', getComponentName(fiber.type), + getStackByFiberInDevAndProd(fiber) ); } } From b5e0873d2e5bffd5ffdbc1f2c8f9bb6864ba0f6a Mon Sep 17 00:00:00 2001 From: Sunil Pai Date: Thu, 14 Feb 2019 16:53:57 +0000 Subject: [PATCH 2/3] pass tests --- packages/react-dom/src/__tests__/ReactTestUtils-test.js | 7 +++---- packages/react-reconciler/src/ReactFiberScheduler.js | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/react-dom/src/__tests__/ReactTestUtils-test.js b/packages/react-dom/src/__tests__/ReactTestUtils-test.js index 280908c77a0c5..3e35c28dbc20d 100644 --- a/packages/react-dom/src/__tests__/ReactTestUtils-test.js +++ b/packages/react-dom/src/__tests__/ReactTestUtils-test.js @@ -634,10 +634,9 @@ describe('ReactTestUtils', () => { button.dispatchEvent(new MouseEvent('click', {bubbles: true})); }); expect(button.innerHTML).toBe('2'); - expect(() => setValueRef(1)).toWarnDev( - ['An update to App inside a test was not wrapped in act(...).'], - {withoutStack: 1}, - ); + expect(() => setValueRef(1)).toWarnDev([ + 'An update to App inside a test was not wrapped in act(...).', + ]); document.body.removeChild(container); }); diff --git a/packages/react-reconciler/src/ReactFiberScheduler.js b/packages/react-reconciler/src/ReactFiberScheduler.js index f4b081e69e36e..314e15ae445dd 100644 --- a/packages/react-reconciler/src/ReactFiberScheduler.js +++ b/packages/react-reconciler/src/ReactFiberScheduler.js @@ -1817,7 +1817,7 @@ export function warnIfNotCurrentlyBatchingInDev(fiber: Fiber): void { "This ensures that you're testing the behavior the user would see in the browser." + ' Learn more at https://fb.me/react-wrap-tests-with-act\n%s', getComponentName(fiber.type), - getStackByFiberInDevAndProd(fiber) + getStackByFiberInDevAndProd(fiber), ); } } From 4d50af3daf19ca3b5bf4003ad7c2e1606d32de2f Mon Sep 17 00:00:00 2001 From: Sunil Pai Date: Thu, 14 Feb 2019 17:15:20 +0000 Subject: [PATCH 3/3] nit --- packages/react-reconciler/src/ReactFiberScheduler.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react-reconciler/src/ReactFiberScheduler.js b/packages/react-reconciler/src/ReactFiberScheduler.js index 314e15ae445dd..c15a1d968cc9d 100644 --- a/packages/react-reconciler/src/ReactFiberScheduler.js +++ b/packages/react-reconciler/src/ReactFiberScheduler.js @@ -1815,7 +1815,8 @@ export function warnIfNotCurrentlyBatchingInDev(fiber: Fiber): void { '});\n' + '/* assert on the output */\n\n' + "This ensures that you're testing the behavior the user would see in the browser." + - ' Learn more at https://fb.me/react-wrap-tests-with-act\n%s', + ' Learn more at https://fb.me/react-wrap-tests-with-act' + + '%s', getComponentName(fiber.type), getStackByFiberInDevAndProd(fiber), );