Skip to content

Commit 61b9d73

Browse files
author
Brian Vaughn
committed
Update tests to reflect that createRoot API is no longer strict by default
1 parent f9648f1 commit 61b9d73

12 files changed

+137
-266
lines changed

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

+4-10
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,10 @@ describe('ReactTestUtils.act()', () => {
9797
});
9898

9999
// @gate experimental
100-
it('warns in concurrent mode', () => {
101-
expect(() => {
102-
const root = ReactDOM.unstable_createRoot(
103-
document.createElement('div'),
104-
);
105-
root.render(<App />);
106-
Scheduler.unstable_flushAll();
107-
}).toErrorDev([
108-
'An update to App ran an effect, but was not wrapped in act(...)',
109-
]);
100+
it('does not warn in concurrent mode', () => {
101+
const root = ReactDOM.unstable_createRoot(document.createElement('div'));
102+
root.render(<App />);
103+
Scheduler.unstable_flushAll();
110104
});
111105
});
112106
});

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

-2
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ describe('DebugTracing', () => {
282282
expect(logs).toEqual([
283283
`group: ⚛️ render (${DEFAULT_LANE_STRING})`,
284284
`log: ⚛️ Example updated state (${DEFAULT_LANE_STRING})`,
285-
`log: ⚛️ Example updated state (${DEFAULT_LANE_STRING})`,
286285
`groupEnd: ⚛️ render (${DEFAULT_LANE_STRING})`,
287286
]);
288287
});
@@ -366,7 +365,6 @@ describe('DebugTracing', () => {
366365
expect(logs).toEqual([
367366
`group: ⚛️ render (${DEFAULT_LANE_STRING})`,
368367
`log: ⚛️ Example updated state (${DEFAULT_LANE_STRING})`,
369-
`log: ⚛️ Example updated state (${DEFAULT_LANE_STRING})`, // debugRenderPhaseSideEffectsForStrictMode
370368
`groupEnd: ⚛️ render (${DEFAULT_LANE_STRING})`,
371369
]);
372370
});

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

+7-20
Original file line numberDiff line numberDiff line change
@@ -517,11 +517,7 @@ describe('ReactHooksWithNoopRenderer', () => {
517517
</>,
518518
);
519519
expect(() =>
520-
expect(Scheduler).toFlushAndYield(
521-
__DEV__
522-
? ['Foo [0]', 'Bar', 'Foo [2]']
523-
: ['Foo [0]', 'Bar', 'Foo [1]'],
524-
),
520+
expect(Scheduler).toFlushAndYield(['Foo [0]', 'Bar', 'Foo [1]']),
525521
).toErrorDev([
526522
'Cannot update a component (`Foo`) while rendering a ' +
527523
'different component (`Bar`). To locate the bad setState() call inside `Bar`',
@@ -536,11 +532,7 @@ describe('ReactHooksWithNoopRenderer', () => {
536532
<Bar triggerUpdate={true} />
537533
</>,
538534
);
539-
expect(Scheduler).toFlushAndYield(
540-
__DEV__
541-
? ['Foo [2]', 'Bar', 'Foo [4]']
542-
: ['Foo [1]', 'Bar', 'Foo [2]'],
543-
);
535+
expect(Scheduler).toFlushAndYield(['Foo [1]', 'Bar', 'Foo [2]']);
544536
});
545537
});
546538

@@ -1762,16 +1754,11 @@ describe('ReactHooksWithNoopRenderer', () => {
17621754
return <Text text={'Count: ' + count} />;
17631755
}
17641756

1765-
// we explicitly wait for missing act() warnings here since
1766-
// it's a lot harder to simulate this condition inside an act scope
1767-
expect(() => {
1768-
ReactNoop.render(<Counter count={0} />, () =>
1769-
Scheduler.unstable_yieldValue('Sync effect'),
1770-
);
1771-
expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1772-
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
1773-
}).toErrorDev(['An update to Counter ran an effect']);
1774-
1757+
ReactNoop.render(<Counter count={0} />, () =>
1758+
Scheduler.unstable_yieldValue('Sync effect'),
1759+
);
1760+
expect(Scheduler).toFlushAndYieldThrough(['Count: 0', 'Sync effect']);
1761+
expect(ReactNoop.getChildren()).toEqual([span('Count: 0')]);
17751762
// A flush sync doesn't cause the passive effects to fire.
17761763
// So we haven't added the other update yet.
17771764
act(() => {

0 commit comments

Comments
 (0)