Skip to content

Commit 9c48fb2

Browse files
authored
Remove ReactTestUtils from refs-destruction-test (#28532)
```diff -expect(ReactTestUtils.isDOMComponent(maybeElement)).toBe(true); +expect(maybeElement).toBeInstanceOf(Element); ``` It's not equivalent since `isDOMComponent` checks `maybeElement.nodeType === Element.ELEMENT_NODE && !!maybeElement.tagName` but `instanceof` check seems sufficient here. Checking `nodeType` is mostly for cross-realm checks and checking falsy `tagName` seems like a check specifically for incomplete DOM implementations because tagName can't be empty by spec I believe.
1 parent 58cd0ef commit 9c48fb2

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

packages/react-dom/src/__tests__/refs-destruction-test.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
let React;
1313
let ReactDOM;
1414
let ReactDOMClient;
15-
let ReactTestUtils;
1615
let TestComponent;
1716
let act;
1817
let theInnerDivRef;
@@ -25,7 +24,6 @@ describe('refs-destruction', () => {
2524
React = require('react');
2625
ReactDOM = require('react-dom');
2726
ReactDOMClient = require('react-dom/client');
28-
ReactTestUtils = require('react-dom/test-utils');
2927
act = require('internal-test-utils').act;
3028

3129
class ClassComponent extends React.Component {
@@ -75,7 +73,7 @@ describe('refs-destruction', () => {
7573
root.render(<TestComponent />);
7674
});
7775

78-
expect(ReactTestUtils.isDOMComponent(theInnerDivRef.current)).toBe(true);
76+
expect(theInnerDivRef.current).toBeInstanceOf(Element);
7977
expect(theInnerClassComponentRef.current).toBeTruthy();
8078

8179
root.unmount();
@@ -91,7 +89,7 @@ describe('refs-destruction', () => {
9189
root.render(<TestComponent />);
9290
});
9391

94-
expect(ReactTestUtils.isDOMComponent(theInnerDivRef.current)).toBe(true);
92+
expect(theInnerDivRef.current).toBeInstanceOf(Element);
9593
expect(theInnerClassComponentRef.current).toBeTruthy();
9694

9795
await act(async () => {
@@ -109,7 +107,7 @@ describe('refs-destruction', () => {
109107
root.render(<TestComponent />);
110108
});
111109

112-
expect(ReactTestUtils.isDOMComponent(theInnerDivRef.current)).toBe(true);
110+
expect(theInnerDivRef.current).toBeInstanceOf(Element);
113111
expect(theInnerClassComponentRef.current).toBeTruthy();
114112

115113
await act(async () => {

0 commit comments

Comments
 (0)