11import * as React from 'react' ;
22import type { HostElement , JsonElement , Root , RootOptions } from 'universal-test-renderer' ;
33
4- import act from '../act' ;
5- import { addToCleanupQueue } from '../cleanup' ;
6- import { getConfig } from '../config' ;
7- import type { DebugOptions } from '../helpers/debug' ;
8- import { debug } from '../helpers/debug' ;
9- import { renderWithAct } from '../render-act' ;
10- import { setRenderResult } from '../screen' ;
11- import { getQueriesForElement } from '../within' ;
4+ import act from './act' ;
5+ import { addToCleanupQueue } from './cleanup' ;
6+ import { getConfig } from './config' ;
7+ import type { DebugOptions } from './helpers/debug' ;
8+ import { debug } from './helpers/debug' ;
9+ import { HOST_TEXT_NAMES } from './helpers/host-component-names' ;
10+ import { renderWithAct } from './render-act' ;
11+ import { setRenderResult } from './screen' ;
12+ import { getQueriesForElement } from './within' ;
1213
1314export interface RenderSyncOptions {
1415 /**
@@ -18,15 +19,15 @@ export interface RenderSyncOptions {
1819 // eslint-disable-next-line @typescript-eslint/no-explicit-any
1920 wrapper ?: React . ComponentType < any > ;
2021
21- createNodeMock ?: ( element : React . ReactElement ) => unknown ;
22+ createNodeMock ?: ( element : React . ReactElement ) => object ;
2223}
2324
2425/**
2526 * @deprecated Use `render` (async) instead. This function is provided for migration purposes only.
2627 * Renders test component deeply using React Test Renderer and exposes helpers
2728 * to assert on the output.
2829 */
29- export default function unsafe_renderSync < T > (
30+ export function unsafe_renderSync < T > (
3031 component : React . ReactElement < T > ,
3132 options : RenderSyncOptions = { } ,
3233) {
@@ -36,10 +37,12 @@ export default function unsafe_renderSync<T>(
3637export type RenderSyncResult = ReturnType < typeof unsafe_renderSync > ;
3738
3839export function renderInternal < T > ( component : React . ReactElement < T > , options ?: RenderSyncOptions ) {
39- const { wrapper : Wrapper } = options || { } ;
40+ const { wrapper : Wrapper , createNodeMock } = options || { } ;
4041
41- // TODO allow passing some options
42- const rendererOptions : RootOptions = { } ;
42+ const rendererOptions : RootOptions = {
43+ textComponents : HOST_TEXT_NAMES ,
44+ createNodeMock,
45+ } ;
4346
4447 const wrap = ( element : React . ReactElement ) => ( Wrapper ? < Wrapper > { element } </ Wrapper > : element ) ;
4548 const renderer = renderWithAct ( wrap ( component ) , rendererOptions ) ;
0 commit comments