Test :Add a small test for ReactTestUtils to find rendered component with type in document (#24368)
I tried to write test for the ReactTestUtils to find rendered component with type in document Tests before this PR  Tests after this PR 
BIKI DAS committed
Feb 17, 2023 at 16:53 UTC
4fcc9184ac2662186cbf1470005bf2b7c67dd40b
1 file changed
+15
packages/react-dom/src/__tests__/ReactTestUtils-test.js
+15
@@ -463,4 +463,19 @@ describe('ReactTestUtils', () => {
463
ReactTestUtils.renderIntoDocument(<Component />);
464
expect(mockArgs.length).toEqual(0);
465
});
466
+ it('should find rendered component with type in document', () => {
467
+ class MyComponent extends React.Component {
468
+ render() {
469
+ return true;
470
+ }
471
+ }
472
+
473
+ const instance = ReactTestUtils.renderIntoDocument(<MyComponent />);
474
+ const renderedComponentType = ReactTestUtils.findRenderedComponentWithType(
475
+ instance,
476
+ MyComponent,
477
+ );
478
+
479
+ expect(renderedComponentType).toBe(instance);
480
+ });
481
});