我有一个这样的组件:
<Parent>
<Child/>
</Parent>
Run Code Online (Sandbox Code Playgroud)
和<Child/>组件有一个方法foo.我想测试foo方法,但我不知道如何访问它.我试过了:
mount(<Parent><Child/></Parent>).props().children.foo
Run Code Online (Sandbox Code Playgroud)
要么
mount(<Parent><Child/></Parent>).children().foo
Run Code Online (Sandbox Code Playgroud)
但他们都是undefined.我无法使用,.instance()因为它不是root.我无法挂载<Child/>只是因为<Parent>添加了一些东西(react-router's context.router),context而我在init时需要它们<Child/>.有这个想法吗?