Skip to content

Commit

Permalink
Include component stack in 'act(...)' warning (#14855)
Browse files Browse the repository at this point in the history
* add a component stack trace to the act() warning

* pass tests

* nit
  • Loading branch information
Sunil Pai authored and gaearon committed Feb 14, 2019
1 parent ff188d6 commit c555c00
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 3 additions & 4 deletions packages/react-dom/src/__tests__/ReactTestUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down
4 changes: 3 additions & 1 deletion packages/react-reconciler/src/ReactFiberScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -1839,8 +1839,10 @@ 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' +
'%s',
getComponentName(fiber.type),
getStackByFiberInDevAndProd(fiber),
);
}
}
Expand Down

0 comments on commit c555c00

Please sign in to comment.