Skip to content

Commit

Permalink
a better message, consistent with the state update one.
Browse files Browse the repository at this point in the history
  • Loading branch information
threepointone committed Jun 24, 2019
1 parent c777608 commit b8202ba
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
8 changes: 4 additions & 4 deletions packages/react-dom/src/__tests__/ReactDOMHooks-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ describe('ReactDOMHooks', () => {
expect(container2.textContent).toBe('4');
expect(container3.textContent).toBe('6');
}).toWarnDev([
'Your test just caused an effect from Example1',
'Your test just caused an effect from Example2',
'Your test just caused an effect from Example1',
'Your test just caused an effect from Example2',
'An update to Example1 ran an effect',
'An update to Example2 ran an effect',
'An update to Example1 ran an effect',
'An update to Example2 ran an effect',
]);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberWorkLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -2434,7 +2434,7 @@ export function warnIfNotCurrentlyActingEffectsInDEV(fiber: Fiber): void {
if (ReactCurrentActingRendererSigil.current !== ReactActingRendererSigil) {
warningWithoutStack(
false,
'Your test just caused an effect from %s, but was not wrapped in act(...).\n\n' +
'An update to %s ran an effect, but was not wrapped in act(...).\n\n' +
'When testing, code that causes React state updates should be ' +
'wrapped into act(...):\n\n' +
'act(() => {\n' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1800,7 +1800,7 @@ describe('ReactHooks', () => {
globalListener();
globalListener();
}).toWarnDev([
'Your test just caused an effect from C',
'An update to C ran an effect',
'An update to C inside a test was not wrapped in act',
'An update to C inside a test was not wrapped in act',
// Note: should *not* warn about updates on unmounted component.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -885,14 +885,13 @@ describe('ReactHooksWithNoopRenderer', () => {

// we explicitly wait for missing act() warnings here since
// it's a lot harder to simulate this condition inside an act scope
// todo - is this ok?
expect(() => {
ReactNoop.render(<Counter count={0} />, () =>
Scheduler.yieldValue('Sync effect'),
);
expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
}).toWarnDev(['Your test just caused an effect from Counter']);
}).toWarnDev(['An update to Counter ran an effect']);

// A discrete event forces the passive effect to be flushed --
// updateCount(1) happens first, so 2 wins.
Expand All @@ -907,8 +906,8 @@ describe('ReactHooksWithNoopRenderer', () => {
expect(() => {
expect(Scheduler).toFlushAndYield(['Count: 2']);
}).toWarnDev([
'Your test just caused an effect from Counter',
'Your test just caused an effect from Counter',
'An update to Counter ran an effect',
'An update to Counter ran an effect',
]);

expect(ReactNoop.getChildren()).toEqual([span('Count: 2')]);
Expand Down Expand Up @@ -943,7 +942,6 @@ describe('ReactHooksWithNoopRenderer', () => {
const tracingEvent = {id: 0, name: 'hello', timestamp: 0};
// we explicitly wait for missing act() warnings here since
// it's a lot harder to simulate this condition inside an act scope
// todo - is this ok?
expect(() => {
SchedulerTracing.unstable_trace(
tracingEvent.name,
Expand All @@ -956,7 +954,7 @@ describe('ReactHooksWithNoopRenderer', () => {
);
expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
}).toWarnDev(['Your test just caused an effect from Counter']);
}).toWarnDev(['An update to Counter ran an effect']);

expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(0);

Expand All @@ -973,8 +971,8 @@ describe('ReactHooksWithNoopRenderer', () => {
expect(() => {
expect(Scheduler).toFlushAndYield(['Count: 2']);
}).toWarnDev([
'Your test just caused an effect from Counter',
'Your test just caused an effect from Counter',
'An update to Counter ran an effect',
'An update to Counter ran an effect',
]);

expect(ReactNoop.getChildren()).toEqual([span('Count: 2')]);
Expand Down

0 comments on commit b8202ba

Please sign in to comment.