I'm using mocha/chai/enzyme/sinon to test my React components. Suppose I am looking to test the following component, and that I need to mount
it in order to test lifecycle methods.
<Container>
<div />
<NestedContainer />
<div />
</Container>
Suppose further that I do not want to in any case mount the component NestedContainer
. Instead what I would like to do, is mock/stub out NestedContainer
with a plain old div
before mounting Container
.
I've looked for solutions online to do this, and the only relevant resource I've found is this: https://medium.com/@AndreCalvo/react-component-testing-mocking-method-calls-components-and-time-d780d45e4cd5. It seems kind of heavy to bring in a large library to mock these components.
Does anyone know of any other way to do this? Thanks.