@@ -466,7 +507,10 @@ describe('ReactDOMTestSelectors', () => {
);
}
- render(
, container);
+ const root = createRoot(container);
+ await act(() => {
+ root.render(
);
+ });
const matches = findAllNodes(document.body, [
createComponentSelector(Example),
@@ -489,13 +533,16 @@ describe('ReactDOMTestSelectors', () => {
});
// @gate www || experimental
- it('should throw if an invalid host root is specified', () => {
+ it('should throw if an invalid host root is specified', async () => {
const ref = React.createRef();
function Example() {
return
, container);
+ const root = createRoot(container);
+ await act(() => {
+ root.render(
);
+ });
expect(() => findAllNodes(ref.current, [])).toThrow(
'Invalid host root specified. Should be either a React container or a node with a testname attribute.',
@@ -505,7 +552,7 @@ describe('ReactDOMTestSelectors', () => {
describe('getFindAllNodesFailureDescription', () => {
// @gate www || experimental
- it('should describe findAllNodes failures caused by the component type selector', () => {
+ it('should describe findAllNodes failures caused by the component type selector', async () => {
function Outer() {
return
;
}
@@ -516,7 +563,10 @@ describe('ReactDOMTestSelectors', () => {
return
, container);
+ const root = createRoot(container);
+ await act(() => {
+ root.render(
);
+ });
const description = getFindAllNodesFailureDescription(document.body, [
createComponentSelector(Outer),
@@ -535,7 +585,7 @@ No matching component was found for:
});
// @gate www || experimental
- it('should return null if findAllNodes was able to find a match', () => {
+ it('should return null if findAllNodes was able to find a match', async () => {
function Example() {
return (
@@ -544,7 +594,10 @@ No matching component was found for:
);
}
- render(
, container);
+ const root = createRoot(container);
+ await act(() => {
+ root.render(
);
+ });
const description = getFindAllNodesFailureDescription(document.body, [
createComponentSelector(Example),
@@ -571,7 +624,7 @@ No matching component was found for:
}
// @gate www || experimental
- it('should return a single rect for a component that returns a single root host element', () => {
+ it('should return a single rect for a component that returns a single root host element', async () => {
const ref = React.createRef();
function Example() {
@@ -583,7 +636,10 @@ No matching component was found for:
);
}
- render(
, container);
+ const root = createRoot(container);
+ await act(() => {
+ root.render(
);
+ });
setBoundingClientRect(ref.current, {
x: 10,
@@ -605,7 +661,7 @@ No matching component was found for:
});
// @gate www || experimental
- it('should return a multiple rects for multiple matches', () => {
+ it('should return a multiple rects for multiple matches', async () => {
const outerRef = React.createRef();
const innerRef = React.createRef();
@@ -621,7 +677,10 @@ No matching component was found for:
return
;
}
- render(
, container);
+ const root = createRoot(container);
+ await act(() => {
+ root.render(
);
+ });
setBoundingClientRect(outerRef.current, {
x: 10,
@@ -655,7 +714,7 @@ No matching component was found for:
});
// @gate www || experimental
- it('should return a multiple rects for single match that returns a fragment', () => {
+ it('should return a multiple rects for single match that returns a fragment', async () => {
const refA = React.createRef();
const refB = React.createRef();
@@ -671,7 +730,10 @@ No matching component was found for:
);
}
- render(
, container);
+ const root = createRoot(container);
+ await act(() => {
+ root.render(
);
+ });
setBoundingClientRect(refA.current, {
x: 10,
@@ -705,7 +767,7 @@ No matching component was found for:
});
// @gate www || experimental
- it('should merge overlapping rects', () => {
+ it('should merge overlapping rects', async () => {
const refA = React.createRef();
const refB = React.createRef();
const refC = React.createRef();
@@ -720,7 +782,10 @@ No matching component was found for:
);
}
- render(
, container);
+ const root = createRoot(container);
+ await act(() => {
+ root.render(
);
+ });
setBoundingClientRect(refA.current, {
x: 10,
@@ -760,7 +825,7 @@ No matching component was found for:
});
// @gate www || experimental
- it('should merge some types of adjacent rects (if they are the same in one dimension)', () => {
+ it('should merge some types of adjacent rects (if they are the same in one dimension)', async () => {
const refA = React.createRef();
const refB = React.createRef();
const refC = React.createRef();
@@ -783,7 +848,10 @@ No matching component was found for:
);
}
- render(
, container);
+ const root = createRoot(container);
+ await act(() => {
+ root.render(
);
+ });
// A, B, and C are all adjacent and/or overlapping, with the same height.
setBoundingClientRect(refA.current, {
@@ -860,7 +928,7 @@ No matching component was found for:
});
// @gate www || experimental
- it('should not search within hidden subtrees', () => {
+ it('should not search within hidden subtrees', async () => {
const refA = React.createRef();
const refB = React.createRef();
const refC = React.createRef();
@@ -875,7 +943,10 @@ No matching component was found for:
);
}
- render(
, container);
+ const root = createRoot(container);
+ await act(() => {
+ root.render(
);
+ });
setBoundingClientRect(refA.current, {
x: 10,
@@ -917,7 +988,7 @@ No matching component was found for:
describe('focusWithin', () => {
// @gate www || experimental
- it('should return false if the specified component path has no matches', () => {
+ it('should return false if the specified component path has no matches', async () => {
function Example() {
return
;
}
@@ -928,7 +999,10 @@ No matching component was found for:
return null;
}
- render(
, container);
+ const root = createRoot(container);
+ await act(() => {
+ root.render(
);
+ });
const didFocus = focusWithin(document.body, [
createComponentSelector(Example),
@@ -938,7 +1012,7 @@ No matching component was found for:
});
// @gate www || experimental
- it('should return false if there are no focusable elements within the matched subtree', () => {
+ it('should return false if there are no focusable elements within the matched subtree', async () => {
function Example() {
return
;
}
@@ -946,7 +1020,10 @@ No matching component was found for:
return 'not focusable';
}
- render(
, container);
+ const root = createRoot(container);
+ await act(() => {
+ root.render(
);
+ });
const didFocus = focusWithin(document.body, [
createComponentSelector(Example),
@@ -956,7 +1033,7 @@ No matching component was found for:
});
// @gate www || experimental
- it('should return false if the only focusable elements are disabled', () => {
+ it('should return false if the only focusable elements are disabled', async () => {
function Example() {
return (
@@ -965,7 +1042,10 @@ No matching component was found for:
);
}
- render( , container);
+ const root = createRoot(container);
+ await act(() => {
+ root.render( );
+ });
const didFocus = focusWithin(document.body, [
createComponentSelector(Example),
@@ -974,12 +1054,15 @@ No matching component was found for:
});
// @gate www || experimental
- it('should return false if the only focusable elements are hidden', () => {
+ it('should return false if the only focusable elements are hidden', async () => {
function Example() {
return not clickable ;
}
- render( , container);
+ const root = createRoot(container);
+ await act(() => {
+ root.render( );
+ });
const didFocus = focusWithin(document.body, [
createComponentSelector(Example),
@@ -988,7 +1071,7 @@ No matching component was found for:
});
// @gate www || experimental
- it('should successfully focus the first focusable element within the tree', () => {
+ it('should successfully focus the first focusable element within the tree', async () => {
const secondRef = React.createRef(null);
const handleFirstFocus = jest.fn();
@@ -1029,7 +1112,10 @@ No matching component was found for:
);
}
- render( , container);
+ const root = createRoot(container);
+ await act(() => {
+ root.render( );
+ });
const didFocus = focusWithin(document.body, [
createComponentSelector(Example),
@@ -1043,7 +1129,7 @@ No matching component was found for:
});
// @gate www || experimental
- it('should successfully focus the first focusable element even if application logic interferes', () => {
+ it('should successfully focus the first focusable element even if application logic interferes', async () => {
const ref = React.createRef(null);
const handleFocus = jest.fn(event => {
@@ -1061,7 +1147,10 @@ No matching component was found for:
);
}
- render( , container);
+ const root = createRoot(container);
+ await act(() => {
+ root.render( );
+ });
const didFocus = focusWithin(document.body, [
createComponentSelector(Example),
@@ -1073,7 +1162,7 @@ No matching component was found for:
});
// @gate www || experimental
- it('should not focus within hidden subtrees', () => {
+ it('should not focus within hidden subtrees', async () => {
const secondRef = React.createRef(null);
const handleFirstFocus = jest.fn();
@@ -1116,7 +1205,10 @@ No matching component was found for:
);
}
- render( , container);
+ const root = createRoot(container);
+ await act(() => {
+ root.render( );
+ });
const didFocus = focusWithin(document.body, [
createComponentSelector(Example),
@@ -1197,14 +1289,17 @@ No matching component was found for:
});
// @gate www || experimental
- it('should notify a listener when the underlying instance intersection changes', () => {
+ it('should notify a listener when the underlying instance intersection changes', async () => {
const ref = React.createRef(null);
function Example() {
return
;
}
- render( , container);
+ const root = createRoot(container);
+ await act(() => {
+ root.render( );
+ });
// Stub out the size of the element this test will be observing.
const rect = {
@@ -1234,7 +1329,7 @@ No matching component was found for:
});
// @gate www || experimental
- it('should notify a listener of multiple targets when the underlying instance intersection changes', () => {
+ it('should notify a listener of multiple targets when the underlying instance intersection changes', async () => {
const ref1 = React.createRef(null);
const ref2 = React.createRef(null);
@@ -1247,7 +1342,10 @@ No matching component was found for:
);
}
- render( , container);
+ const root = createRoot(container);
+ await act(() => {
+ root.render( );
+ });
// Stub out the size of the element this test will be observing.
const rect1 = {
@@ -1311,14 +1409,17 @@ No matching component was found for:
});
// @gate www || experimental
- it('should stop listening when its disconnected', () => {
+ it('should stop listening when its disconnected', async () => {
const ref = React.createRef(null);
function Example() {
return
;
}
- render( , container);
+ const root = createRoot(container);
+ await act(() => {
+ root.render( );
+ });
// Stub out the size of the element this test will be observing.
const rect = {
@@ -1346,7 +1447,7 @@ No matching component was found for:
// This test reuires gating because it relies on the __DEV__ only commit hook to work.
// @gate www || experimental && __DEV__
- it('should update which targets its listening to after a commit', () => {
+ it('should update which targets its listening to after a commit', async () => {
const ref1 = React.createRef(null);
const ref2 = React.createRef(null);
@@ -1363,7 +1464,10 @@ No matching component was found for:
);
}
- render( , container);
+ const root = createRoot(container);
+ await act(() => {
+ root.render( );
+ });
// Stub out the size of the element this test will be observing.
const rect1 = {
@@ -1389,7 +1493,7 @@ No matching component was found for:
{rect: rect1, ratio: 1},
]);
- act(() => increment());
+ await act(() => increment());
const rect2 = {
x: 110,
@@ -1412,7 +1516,7 @@ No matching component was found for:
{rect: rect2, ratio: 0.25},
]);
- act(() => increment());
+ await act(() => increment());
handleVisibilityChange.mockClear();
@@ -1425,7 +1529,7 @@ No matching component was found for:
});
// @gate www || experimental
- it('should not observe components within hidden subtrees', () => {
+ it('should not observe components within hidden subtrees', async () => {
const ref1 = React.createRef(null);
const ref2 = React.createRef(null);
@@ -1438,7 +1542,10 @@ No matching component was found for:
);
}
- render( , container);
+ const root = createRoot(container);
+ await act(() => {
+ root.render( );
+ });
// Stub out the size of the element this test will be observing.
const rect1 = {
diff --git a/packages/react-dom/unstable_testing.classic.fb.js b/packages/react-dom/unstable_testing.classic.fb.js
index 2f623787958d3..6dd68f3669dc3 100644
--- a/packages/react-dom/unstable_testing.classic.fb.js
+++ b/packages/react-dom/unstable_testing.classic.fb.js
@@ -7,7 +7,31 @@
* @flow
*/
-export * from './index.classic.fb.js';
+export {
+ createPortal,
+ findDOMNode,
+ flushSync,
+ hydrate,
+ render,
+ unmountComponentAtNode,
+ unstable_batchedUpdates,
+ unstable_createEventHandle,
+ unstable_renderSubtreeIntoContainer,
+ unstable_runWithPriority, // DO NOT USE: Temporarily exposed to migrate off of Scheduler.runWithPriority.
+ useFormStatus,
+ useFormState,
+ prefetchDNS,
+ preconnect,
+ preload,
+ preloadModule,
+ preinit,
+ preinitModule,
+ version,
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
+} from './index.classic.fb.js';
+
+export {createRoot, hydrateRoot} from './client.js';
+
export {
createComponentSelector,
createHasPseudoClassSelector,
diff --git a/packages/react-dom/unstable_testing.experimental.js b/packages/react-dom/unstable_testing.experimental.js
index 3ed081d85b9b1..b84561272bef3 100644
--- a/packages/react-dom/unstable_testing.experimental.js
+++ b/packages/react-dom/unstable_testing.experimental.js
@@ -7,7 +7,29 @@
* @flow
*/
-export * from './index.experimental.js';
+export {
+ createPortal,
+ findDOMNode,
+ flushSync,
+ hydrate,
+ render,
+ unmountComponentAtNode,
+ unstable_batchedUpdates,
+ unstable_renderSubtreeIntoContainer,
+ useFormStatus,
+ useFormState,
+ prefetchDNS,
+ preconnect,
+ preload,
+ preloadModule,
+ preinit,
+ preinitModule,
+ version,
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
+} from './index.experimental.js';
+
+export {createRoot, hydrateRoot} from './client.js';
+
export {
createComponentSelector,
createHasPseudoClassSelector,
diff --git a/packages/react-dom/unstable_testing.js b/packages/react-dom/unstable_testing.js
index fdad56d13c77d..9729a427e4aa6 100644
--- a/packages/react-dom/unstable_testing.js
+++ b/packages/react-dom/unstable_testing.js
@@ -7,7 +7,30 @@
* @flow
*/
-export * from './index.js';
+export {
+ createPortal,
+ findDOMNode,
+ flushSync,
+ hydrate,
+ render,
+ unmountComponentAtNode,
+ unstable_batchedUpdates,
+ unstable_createEventHandle,
+ unstable_renderSubtreeIntoContainer,
+ unstable_runWithPriority, // DO NOT USE: Temporarily exposed to migrate off of Scheduler.runWithPriority.
+ useFormStatus,
+ useFormState,
+ prefetchDNS,
+ preconnect,
+ preload,
+ preloadModule,
+ preinit,
+ preinitModule,
+ version,
+} from './index.js';
+
+export {createRoot, hydrateRoot} from './client.js';
+
export {
createComponentSelector,
createHasPseudoClassSelector,
diff --git a/packages/react-dom/unstable_testing.modern.fb.js b/packages/react-dom/unstable_testing.modern.fb.js
index c0a0e45ad79ca..17e78ae012adc 100644
--- a/packages/react-dom/unstable_testing.modern.fb.js
+++ b/packages/react-dom/unstable_testing.modern.fb.js
@@ -7,7 +7,23 @@
* @flow
*/
-export * from './index.modern.fb.js';
+export {
+ createPortal,
+ flushSync,
+ unstable_batchedUpdates,
+ unstable_createEventHandle,
+ useFormStatus,
+ useFormState,
+ prefetchDNS,
+ preconnect,
+ preload,
+ preloadModule,
+ preinit,
+ preinitModule,
+ version,
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
+} from './index.modern.fb.js';
+export {createRoot, hydrateRoot} from './client.js';
export {
createComponentSelector,
createHasPseudoClassSelector,
diff --git a/packages/react-dom/unstable_testing.stable.js b/packages/react-dom/unstable_testing.stable.js
index b983e17bef9bd..453e8b4fdece7 100644
--- a/packages/react-dom/unstable_testing.stable.js
+++ b/packages/react-dom/unstable_testing.stable.js
@@ -7,4 +7,24 @@
* @flow
*/
-export * from './index.stable.js';
+export {
+ createPortal,
+ findDOMNode,
+ flushSync,
+ hydrate,
+ render,
+ unmountComponentAtNode,
+ unstable_batchedUpdates,
+ unstable_renderSubtreeIntoContainer,
+ useFormStatus,
+ useFormState,
+ prefetchDNS,
+ preconnect,
+ preload,
+ preloadModule,
+ preinit,
+ preinitModule,
+ version,
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
+} from './index.stable.js';
+export {createRoot, hydrateRoot} from './client.js';