Closed macrozone closed 7 years ago
You can stub the container or you can create a separate container component and test the inside component with props
that don't depend on the container.
The whole point of the container concept is to separate the data-fetching concerns from the rendering concerns.
You should be testing the component with plain data, not with whatever data is being fetched and passed in from the container.
I am aware of this. The problem is, that i am testing a component that contains a container-component as child. The component under test itself is just a component, not a container.
E.g. the component under test is MainLayout:
<MainLayout>
<MyContainer />
(...)
</MainLayout>
MyContainer in this sample just happens to be a container. It should not matter if it is a component or a container. When I test MainLayout i just want to make sure that MyContainer is there (or other aspects of MainLayout).
As far as i know, enzyme's shallow should not render child-components, but it does in this case.
And you tried using the stubbing flag as well and it's still not working?
I think now we've better support for stubbing.
I am open to suggestion with the 2.x - https://github.com/kadirahq/react-komposer/issues/123
I have a component that contains a komposed container
If I test this with enzyme, it will crash, because it runs MyContainer's compose function that uses actions or other things from the context which isn't available on test.
Any idea?