Javascript 如何对React中render()中定义为const的函数执行单元测试?

Javascript 如何对React中render()中定义为const的函数执行单元测试?,javascript,reactjs,jestjs,enzyme,Javascript,Reactjs,Jestjs,Enzyme,如果在render()中定义了一个函数,如何为它添加单元测试 export class Foo extends React.Component { componentDidMount() { ...do something... } render() { const ConditionalWrapper = ({ condition, wrapper, children }) => condition ? wrapper(children) : ch

如果在render()中定义了一个函数,如何为它添加单元测试

export class Foo extends React.Component {
  componentDidMount() {
   ...do something...
  }

  render() { 
   const ConditionalWrapper = ({ condition, wrapper, children }) =>
      condition ? wrapper(children) : children;

   return (
     <ConditionalWrapper condition={...} wrapper={children => <div> {children} </div>}>
        <...>
     </ConditionalWrapper>
   )
  }
}
导出类Foo扩展React.Component{
componentDidMount(){
…做点什么。。。
}
render(){
const ConditionalWrapper=({condition,wrapper,children})=>
条件?包装(儿童):儿童;
返回(
{儿童}}>
)
}
}

如何使用jest测试render()中定义的ConditionalWrapper函数?

我认为这是不可能的。如果要对其进行单元测试,必须将其移到渲染方法之外。
间接的方法是获取快照,并查找根据条件创建的某些关键术语。

现在的问题太广泛了。
wrapper
HOC如何影响组件的行为?我不会在组件的呈现中定义我的函数我只是一个测试人员:-/