【发布时间】:2021-05-02 15:59:18
【问题描述】:
如何等到子组件加载后才能检查 toMatchSnapshot 整个父组件?
<MyComponent>
<Child1 />
<Child2 />
</MyComponent>
//单元测试
it('test parent component', () => {
let mycomponent = render(<MyComponent />)
expect(mycomponent.asFragment()).toMatchSnapshot()
})
渲染没有子组件。孩子们被装载在例如5 秒.. 有没有办法在不嘲笑孩子的情况下做到这一点?我希望它们自己加载...
【问题讨论】:
标签: reactjs unit-testing react-testing-library