@@ -2,26 +2,32 @@ import * as React from 'react';
22import { versionAwareRender } from '../dom-render' ;
33
44// Create mock functions with implementations
5- const mockRender = jest . fn ( ) ;
6- const mockUnmountComponentAtNode = jest . fn ( ) ;
7- const mockRootRender = jest . fn ( ) ;
8- const mockRootUnmount = jest . fn ( ) ;
9- const mockCreateRoot = jest . fn ( ( ) => ( {
5+ const mockRender = jest . fn ( ) . mockReturnValue ( undefined ) ;
6+ const mockUnmountComponentAtNode = jest . fn ( ) . mockReturnValue ( true ) ;
7+ const mockRootRender = jest . fn ( ) . mockReturnValue ( undefined ) ;
8+ const mockRootUnmount = jest . fn ( ) . mockReturnValue ( undefined ) ;
9+ const mockCreateRoot = jest . fn ( ) . mockReturnValue ( {
1010 render : mockRootRender ,
1111 unmount : mockRootUnmount ,
12- } ) ) ;
12+ } ) ;
1313
1414// Mock modules before importing the module under test
15- jest . mock ( 'react-dom' , ( ) => ( {
16- __esModule : true ,
17- render : mockRender ,
18- unmountComponentAtNode : mockUnmountComponentAtNode ,
19- } ) ) ;
20-
21- jest . mock ( 'react-dom/client' , ( ) => ( {
22- __esModule : true ,
23- createRoot : mockCreateRoot ,
24- } ) ) ;
15+ jest . mock ( 'react-dom' , ( ) => {
16+ const actual = jest . requireActual ( 'react-dom' ) ;
17+ return {
18+ ...actual ,
19+ render : mockRender ,
20+ unmountComponentAtNode : mockUnmountComponentAtNode ,
21+ } ;
22+ } ) ;
23+
24+ jest . mock ( 'react-dom/client' , ( ) => {
25+ const actual = jest . requireActual ( 'react-dom/client' ) ;
26+ return {
27+ ...actual ,
28+ createRoot : mockCreateRoot ,
29+ } ;
30+ } ) ;
2531
2632describe ( 'dom-render' , ( ) => {
2733 const TestComponent = ( ) => < div > Test Component</ div > ;
0 commit comments