I have a wrapped loadableComponent inside another stateless component, I want to check if the loadable it's already rendered, previously with react-loadable, we didn't need to worry about this since with the help of preloadAll() we achieved it, but not sure how to force the load of the component before my assertion happen.
const wrapper = mount(<Wrapper name="test" `/>);
expect(wrapper.find('svg')).toHaveLength(1); // not loaded yet
const Wrapper = (props) => {
const MyLoadable = loadable(() => import('./MyOtherComp');
return (<Errors><MyLoadable /></Errors>);
}
Hey @yanv1991 :wave:,
Thank you for opening an issue. We'll get back to you as soon as we can.
Please, consider supporting us on Open Collective. We give a special attention to issues opened by backers.
If you use Loadable at work, you can also ask your company to sponsor us :heart:.
preloadAll does not exist. You have to wait for the element to be present, like you do in real.
@gregberge that's my goal, but not sure how to achieve that with loadable-component, any suggestions ? I can do that if I have access to my loadable component directly in my test using load but in this case my component is wrapped inside another stateless . Thank you in advance .
With react-testing-library you should be able to wait for the component to be ready.
Most helpful comment
With react-testing-library you should be able to wait for the component to be ready.