Skip to content

Commit b8202ba

Browse files
committed
a better message, consistent with the state update one.
1 parent c777608 commit b8202ba

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ describe('ReactDOMHooks', () => {
7474
expect(container2.textContent).toBe('4');
7575
expect(container3.textContent).toBe('6');
7676
}).toWarnDev([
77-
'Your test just caused an effect from Example1',
78-
'Your test just caused an effect from Example2',
79-
'Your test just caused an effect from Example1',
80-
'Your test just caused an effect from Example2',
77+
'An update to Example1 ran an effect',
78+
'An update to Example2 ran an effect',
79+
'An update to Example1 ran an effect',
80+
'An update to Example2 ran an effect',
8181
]);
8282
});
8383

packages/react-reconciler/src/ReactFiberWorkLoop.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2434,7 +2434,7 @@ export function warnIfNotCurrentlyActingEffectsInDEV(fiber: Fiber): void {
24342434
if (ReactCurrentActingRendererSigil.current !== ReactActingRendererSigil) {
24352435
warningWithoutStack(
24362436
false,
2437-
'Your test just caused an effect from %s, but was not wrapped in act(...).\n\n' +
2437+
'An update to %s ran an effect, but was not wrapped in act(...).\n\n' +
24382438
'When testing, code that causes React state updates should be ' +
24392439
'wrapped into act(...):\n\n' +
24402440
'act(() => {\n' +

packages/react-reconciler/src/__tests__/ReactHooks-test.internal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1800,7 +1800,7 @@ describe('ReactHooks', () => {
18001800
globalListener();
18011801
globalListener();
18021802
}).toWarnDev([
1803-
'Your test just caused an effect from C',
1803+
'An update to C ran an effect',
18041804
'An update to C inside a test was not wrapped in act',
18051805
'An update to C inside a test was not wrapped in act',
18061806
// Note: should *not* warn about updates on unmounted component.

packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.internal.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -885,14 +885,13 @@ describe('ReactHooksWithNoopRenderer', () => {
885885

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

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

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

961959
expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(0);
962960

@@ -973,8 +971,8 @@ describe('ReactHooksWithNoopRenderer', () => {
973971
expect(() => {
974972
expect(Scheduler).toFlushAndYield(['Count: 2']);
975973
}).toWarnDev([
976-
'Your test just caused an effect from Counter',
977-
'Your test just caused an effect from Counter',
974+
'An update to Counter ran an effect',
975+
'An update to Counter ran an effect',
978976
]);
979977

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

0 commit comments

Comments
 (0)