diff --git a/packages/react-devtools-shared/src/__tests__/treeContext-test.js b/packages/react-devtools-shared/src/__tests__/treeContext-test.js
index 38b38a47e4df3..894524762ac88 100644
--- a/packages/react-devtools-shared/src/__tests__/treeContext-test.js
+++ b/packages/react-devtools-shared/src/__tests__/treeContext-test.js
@@ -15,12 +15,12 @@ import type {
StateContext,
} from 'react-devtools-shared/src/devtools/views/Components/TreeContext';
+import {getVersionedRenderImplementation} from './utils';
+
describe('TreeListContext', () => {
let React;
- let ReactDOM;
let TestRenderer: ReactTestRenderer;
let bridge: FrontendBridge;
- let legacyRender;
let store: Store;
let utils;
let withErrorsOrWarningsIgnored;
@@ -36,7 +36,6 @@ describe('TreeListContext', () => {
utils = require('./utils');
utils.beforeEachProfiling();
- legacyRender = utils.legacyRender;
withErrorsOrWarningsIgnored = utils.withErrorsOrWarningsIgnored;
bridge = global.bridge;
@@ -44,7 +43,6 @@ describe('TreeListContext', () => {
store.collapseNodesByDefault = false;
React = require('react');
- ReactDOM = require('react-dom');
TestRenderer = utils.requireTestRenderer();
BridgeContext =
@@ -54,6 +52,8 @@ describe('TreeListContext', () => {
TreeContext = require('react-devtools-shared/src/devtools/views/Components/TreeContext');
});
+ const {render, unmount, createContainer} = getVersionedRenderImplementation();
+
afterEach(() => {
// Reset between tests
dispatch = ((null: any): DispatcherContext);
@@ -89,9 +89,7 @@ describe('TreeListContext', () => {
);
const Child = () => null;
- utils.act(() =>
- legacyRender(, document.createElement('div')),
- );
+ utils.act(() => render());
let renderer;
utils.act(() => (renderer = TestRenderer.create()));
@@ -215,9 +213,7 @@ describe('TreeListContext', () => {
);
const Child = () => null;
- utils.act(() =>
- legacyRender(, document.createElement('div')),
- );
+ utils.act(() => render());
let renderer;
utils.act(() => (renderer = TestRenderer.create()));
@@ -301,9 +297,7 @@ describe('TreeListContext', () => {
);
const Child = () => null;
- utils.act(() =>
- legacyRender(, document.createElement('div')),
- );
+ utils.act(() => render());
let renderer;
utils.act(() => (renderer = TestRenderer.create()));
@@ -391,16 +385,14 @@ describe('TreeListContext', () => {
const Parent = props => props.children || null;
const Child = () => null;
- const container = document.createElement('div');
utils.act(() =>
- legacyRender(
+ render(
,
- container,
),
);
@@ -427,11 +419,10 @@ describe('TreeListContext', () => {
// Remove the child (which should auto-select the parent)
await utils.actAsync(() =>
- legacyRender(
+ render(
,
- container,
),
);
expect(state).toMatchInlineSnapshot(`
@@ -441,7 +432,7 @@ describe('TreeListContext', () => {
`);
// Unmount the root (so that nothing is selected)
- await utils.actAsync(() => ReactDOM.unmountComponentAtNode(container));
+ await utils.actAsync(() => unmount());
expect(state).toMatchInlineSnapshot(``);
});
@@ -459,9 +450,7 @@ describe('TreeListContext', () => {
.map((_, index) => );
const Child = () => null;
- utils.act(() =>
- legacyRender(, document.createElement('div')),
- );
+ utils.act(() => render());
let renderer;
utils.act(() => (renderer = TestRenderer.create()));
@@ -620,9 +609,7 @@ describe('TreeListContext', () => {
.map((_, index) => );
const Child = () => null;
- utils.act(() =>
- legacyRender(, document.createElement('div')),
- );
+ utils.act(() => render());
let renderer;
utils.act(() => (renderer = TestRenderer.create()));
@@ -920,14 +907,13 @@ describe('TreeListContext', () => {
Qux.displayName = `withHOC(${Qux.name})`;
utils.act(() =>
- legacyRender(
+ render(
,
- document.createElement('div'),
),
);
@@ -992,14 +978,13 @@ describe('TreeListContext', () => {
const Baz = () => null;
utils.act(() =>
- legacyRender(
+ render(
,
- document.createElement('div'),
),
);
@@ -1096,15 +1081,12 @@ describe('TreeListContext', () => {
const Bar = () => null;
const Baz = () => null;
- const container = document.createElement('div');
-
utils.act(() =>
- legacyRender(
+ render(
,
- container,
),
);
@@ -1125,13 +1107,12 @@ describe('TreeListContext', () => {
`);
await utils.actAsync(() =>
- legacyRender(
+ render(
,
- container,
),
);
utils.act(() => renderer.update());
@@ -1157,16 +1138,13 @@ describe('TreeListContext', () => {
const Bar = () => null;
const Baz = () => null;
- const container = document.createElement('div');
-
utils.act(() =>
- legacyRender(
+ render(
,
- container,
),
);
@@ -1198,12 +1176,11 @@ describe('TreeListContext', () => {
`);
await utils.actAsync(() =>
- legacyRender(
+ render(
,
- container,
),
);
utils.act(() => renderer.update());
@@ -1243,9 +1220,7 @@ describe('TreeListContext', () => {
);
const Child = () => null;
- utils.act(() =>
- legacyRender(, document.createElement('div')),
- );
+ utils.act(() => render());
let renderer;
utils.act(() => (renderer = TestRenderer.create()));
@@ -1284,8 +1259,7 @@ describe('TreeListContext', () => {
new Array(count).fill(true).map((_, index) => );
const Child = () => null;
- const container = document.createElement('div');
- utils.act(() => legacyRender(, container));
+ utils.act(() => render());
let renderer;
utils.act(() => (renderer = TestRenderer.create()));
@@ -1307,18 +1281,14 @@ describe('TreeListContext', () => {
`);
- await utils.actAsync(() =>
- legacyRender(, container),
- );
+ await utils.actAsync(() => render());
expect(state).toMatchInlineSnapshot(`
[owners]
→ ▾
`);
- await utils.actAsync(() =>
- legacyRender(, container),
- );
+ await utils.actAsync(() => render());
expect(state).toMatchInlineSnapshot(`
[owners]
→
@@ -1329,13 +1299,11 @@ describe('TreeListContext', () => {
const Parent = props => props.children || null;
const Child = () => null;
- const container = document.createElement('div');
utils.act(() =>
- legacyRender(
+ render(
,
- container,
),
);
@@ -1355,7 +1323,7 @@ describe('TreeListContext', () => {
→
`);
- await utils.actAsync(() => legacyRender(, container));
+ await utils.actAsync(() => render());
expect(state).toMatchInlineSnapshot(`
[root]
→
@@ -1369,7 +1337,7 @@ describe('TreeListContext', () => {
→
`);
- await utils.actAsync(() => ReactDOM.unmountComponentAtNode(container));
+ await utils.actAsync(() => unmount());
expect(state).toMatchInlineSnapshot(``);
});
@@ -1387,8 +1355,7 @@ describe('TreeListContext', () => {
);
- const container = document.createElement('div');
- utils.act(() => legacyRender(, container));
+ utils.act(() => render());
let renderer;
utils.act(() => (renderer = TestRenderer.create()));
@@ -1495,13 +1462,12 @@ describe('TreeListContext', () => {
it('should handle when there are no errors/warnings', () => {
utils.act(() =>
- legacyRender(
+ render(
,
- document.createElement('div'),
),
);
@@ -1558,7 +1524,7 @@ describe('TreeListContext', () => {
it('should cycle through the next errors/warnings and wrap around', () => {
withErrorsOrWarningsIgnored(['test-only:'], () =>
utils.act(() =>
- legacyRender(
+ render(
@@ -1566,7 +1532,6 @@ describe('TreeListContext', () => {
,
- document.createElement('div'),
),
),
);
@@ -1619,7 +1584,7 @@ describe('TreeListContext', () => {
it('should cycle through the previous errors/warnings and wrap around', () => {
withErrorsOrWarningsIgnored(['test-only:'], () =>
utils.act(() =>
- legacyRender(
+ render(
@@ -1627,7 +1592,6 @@ describe('TreeListContext', () => {
,
- document.createElement('div'),
),
),
);
@@ -1680,20 +1644,21 @@ describe('TreeListContext', () => {
it('should cycle through the next errors/warnings and wrap around with multiple roots', () => {
withErrorsOrWarningsIgnored(['test-only:'], () => {
utils.act(() => {
- legacyRender(
+ render(
,
,
- document.createElement('div'),
);
- legacyRender(
+
+ createContainer();
+
+ render(
,
- document.createElement('div'),
);
});
});
@@ -1750,20 +1715,21 @@ describe('TreeListContext', () => {
it('should cycle through the previous errors/warnings and wrap around with multiple roots', () => {
withErrorsOrWarningsIgnored(['test-only:'], () => {
utils.act(() => {
- legacyRender(
+ render(
,
,
- document.createElement('div'),
);
- legacyRender(
+
+ createContainer();
+
+ render(
,
- document.createElement('div'),
);
});
});
@@ -1820,7 +1786,7 @@ describe('TreeListContext', () => {
it('should select the next or previous element relative to the current selection', () => {
withErrorsOrWarningsIgnored(['test-only:'], () =>
utils.act(() =>
- legacyRender(
+ render(
@@ -1828,7 +1794,6 @@ describe('TreeListContext', () => {
,
- document.createElement('div'),
),
),
);
@@ -1882,14 +1847,13 @@ describe('TreeListContext', () => {
it('should update correctly when errors/warnings are cleared for a fiber in the list', () => {
withErrorsOrWarningsIgnored(['test-only:'], () =>
utils.act(() =>
- legacyRender(
+ render(
,
- document.createElement('div'),
),
),
);
@@ -1955,12 +1919,11 @@ describe('TreeListContext', () => {
it('should update correctly when errors/warnings are cleared for the currently selected fiber', () => {
withErrorsOrWarningsIgnored(['test-only:'], () =>
utils.act(() =>
- legacyRender(
+ render(
,
- document.createElement('div'),
),
),
);
@@ -1992,18 +1955,15 @@ describe('TreeListContext', () => {
});
it('should update correctly when new errors/warnings are added', () => {
- const container = document.createElement('div');
-
withErrorsOrWarningsIgnored(['test-only:'], () =>
utils.act(() =>
- legacyRender(
+ render(
,
- container,
),
),
);
@@ -2030,14 +1990,13 @@ describe('TreeListContext', () => {
withErrorsOrWarningsIgnored(['test-only:'], () =>
utils.act(() =>
- legacyRender(
+ render(
,
- container,
),
),
);
@@ -2076,12 +2035,11 @@ describe('TreeListContext', () => {
it('should update correctly when all errors/warnings are cleared', () => {
withErrorsOrWarningsIgnored(['test-only:'], () =>
utils.act(() =>
- legacyRender(
+ render(
,
- document.createElement('div'),
),
),
);
@@ -2120,7 +2078,6 @@ describe('TreeListContext', () => {
});
it('should update correctly when elements are added/removed', () => {
- const container = document.createElement('div');
let errored = false;
function ErrorOnce() {
if (!errored) {
@@ -2131,11 +2088,10 @@ describe('TreeListContext', () => {
}
withErrorsOrWarningsIgnored(['test-only:'], () =>
utils.act(() =>
- legacyRender(
+ render(
,
- container,
),
),
);
@@ -2150,12 +2106,11 @@ describe('TreeListContext', () => {
withErrorsOrWarningsIgnored(['test-only:'], () =>
utils.act(() =>
- legacyRender(
+ render(
,
- container,
),
),
);
@@ -2178,7 +2133,6 @@ describe('TreeListContext', () => {
});
it('should update correctly when elements are re-ordered', () => {
- const container = document.createElement('div');
function ErrorOnce() {
const didErrorRef = React.useRef(false);
if (!didErrorRef.current) {
@@ -2189,14 +2143,13 @@ describe('TreeListContext', () => {
}
withErrorsOrWarningsIgnored(['test-only:'], () =>
utils.act(() =>
- legacyRender(
+ render(
,
- container,
),
),
);
@@ -2227,14 +2180,13 @@ describe('TreeListContext', () => {
// Re-order the tree and ensure indices are updated.
withErrorsOrWarningsIgnored(['test-only:'], () =>
utils.act(() =>
- legacyRender(
+ render(
,
- container,
),
),
);
@@ -2261,14 +2213,13 @@ describe('TreeListContext', () => {
// Re-order the tree and ensure indices are updated.
withErrorsOrWarningsIgnored(['test-only:'], () =>
utils.act(() =>
- legacyRender(
+ render(
,
- container,
),
),
);
@@ -2289,7 +2240,7 @@ describe('TreeListContext', () => {
withErrorsOrWarningsIgnored(['test-only:'], () =>
utils.act(() =>
- legacyRender(
+ render(
@@ -2300,7 +2251,6 @@ describe('TreeListContext', () => {
,
- document.createElement('div'),
),
),
);
@@ -2339,7 +2289,7 @@ describe('TreeListContext', () => {
withErrorsOrWarningsIgnored(['test-only:'], () =>
utils.act(() =>
- legacyRender(
+ render(
@@ -2350,7 +2300,6 @@ describe('TreeListContext', () => {
,
- document.createElement('div'),
),
),
);
@@ -2425,7 +2374,7 @@ describe('TreeListContext', () => {
withErrorsOrWarningsIgnored(['test-only:'], () =>
utils.act(() =>
- legacyRender(
+ render(
@@ -2436,7 +2385,6 @@ describe('TreeListContext', () => {
,
- document.createElement('div'),
),
),
);
@@ -2483,12 +2431,11 @@ describe('TreeListContext', () => {
withErrorsOrWarningsIgnored(['test-only:'], () =>
utils.act(() =>
- legacyRender(
+ render(
,
- document.createElement('div'),
),
),
);
@@ -2515,16 +2462,13 @@ describe('TreeListContext', () => {
}
const LazyComponent = React.lazy(() => fakeImport(Child));
- const container = document.createElement('div');
-
withErrorsOrWarningsIgnored(['test-only:'], () =>
utils.act(() =>
- legacyRender(
+ render(
,
- container,
),
),
);
@@ -2538,12 +2482,11 @@ describe('TreeListContext', () => {
await Promise.resolve();
withErrorsOrWarningsIgnored(['test-only:'], () =>
utils.act(() =>
- legacyRender(
+ render(
,
- container,
),
),
);
@@ -2565,15 +2508,12 @@ describe('TreeListContext', () => {
const Fallback = () => ;
- const container = document.createElement('div');
-
withErrorsOrWarningsIgnored(['test-only:'], () =>
utils.act(() =>
- legacyRender(
+ render(
}>
,
- container,
),
),
);
@@ -2590,11 +2530,10 @@ describe('TreeListContext', () => {
await Promise.resolve();
withErrorsOrWarningsIgnored(['test-only:'], () =>
utils.act(() =>
- legacyRender(
+ render(
}>
,
- container,
),
),
);
@@ -2629,16 +2568,14 @@ describe('TreeListContext', () => {
}
}
- const container = document.createElement('div');
withErrorsOrWarningsIgnored(
['test-only:', 'React will try to recreate this component tree'],
() => {
utils.act(() =>
- legacyRender(
+ render(
,
- container,
),
);
},
@@ -2659,7 +2596,7 @@ describe('TreeListContext', () => {
→ ✕
`);
- utils.act(() => ReactDOM.unmountComponentAtNode(container));
+ utils.act(() => unmount());
expect(state).toMatchInlineSnapshot(``);
// Should be a noop
@@ -2693,16 +2630,14 @@ describe('TreeListContext', () => {
}
}
- const container = document.createElement('div');
withErrorsOrWarningsIgnored(
['test-only:', 'React will try to recreate this component tree'],
() => {
utils.act(() =>
- legacyRender(
+ render(
,
- container,
),
);
},
@@ -2723,7 +2658,7 @@ describe('TreeListContext', () => {
→ ✕
`);
- utils.act(() => ReactDOM.unmountComponentAtNode(container));
+ utils.act(() => unmount());
expect(state).toMatchInlineSnapshot(``);
// Should be a noop
@@ -2752,16 +2687,14 @@ describe('TreeListContext', () => {
}
}
- const container = document.createElement('div');
withErrorsOrWarningsIgnored(
['test-only:', 'React will try to recreate this component tree'],
() => {
utils.act(() =>
- legacyRender(
+ render(
,
- container,
),
);
},