From my understanding and from what I have read so far in various answers, not all lifecycle methods are supposed to be run with shallow rendering. Especially componentDidMount
However, I notice that when I do
beforeEach(function () {
fakeComponentDidMount = sinon.stub(Component.prototype, 'componentDidMount');
fakeComponentDidMount.callsFake(function () {});
wrapper = shallow(<Component {...props} />);
});
afterEach(function () {
fakeComponentDidMount.restore();
});
it('calls componentDidMount', function () {
expect(fakeComponentDidMount.called).to.equal(true);
});
the test passes.
So, am I doing something wrong here or have I understood something wrong?