@@ -8,6 +8,13 @@ import { makeStyles } from './makeStyles';
88import { makeResetStyles } from './makeResetStyles' ;
99import { RendererProvider } from './RendererContext' ;
1010import { renderToStyleElements } from './renderToStyleElements' ;
11+ import { useInsertionEffect as _useInsertionEffect } from './useInsertionEffect' ;
12+
13+ jest . mock ( './useInsertionEffect' , ( ) => ( {
14+ useInsertionEffect : jest . fn ( ) ,
15+ } ) ) ;
16+
17+ const useInsertionEffect = _useInsertionEffect as jest . MockedFunction < typeof React . useInsertionEffect > ;
1118
1219describe ( 'createDOMRenderer' , ( ) => {
1320 it ( 'rehydrateCache() avoids double insertion' , ( ) => {
@@ -46,13 +53,20 @@ describe('createDOMRenderer', () => {
4653 // A "server" renders components to static HTML that will be transferred to a client
4754 //
4855
56+ // Heads up!
57+ // Mock there is need as this test is executed in DOM environment and uses "useInsertionEffect".
58+ // However, "useInsertionEffect" will not be called in "renderToStaticMarkup()".
59+ useInsertionEffect . mockImplementation ( fn => fn ( ) ) ;
60+
4961 const componentHTML = renderToStaticMarkup (
5062 < RendererProvider renderer = { serverRenderer } >
5163 < ExampleComponent />
5264 </ RendererProvider > ,
5365 ) ;
5466 const stylesHTML = renderToStaticMarkup ( < > { renderToStyleElements ( serverRenderer ) } </ > ) ;
5567
68+ useInsertionEffect . mockImplementation ( React . useInsertionEffect ) ;
69+
5670 // Ensure that all styles are inserted into the cache
5771 expect ( serverRenderer . insertionCache ) . toMatchInlineSnapshot ( `
5872 Object {
0 commit comments