【发布时间】:2018-04-28 19:21:31
【问题描述】:
根据我的理解以及迄今为止我在各种答案中所读到的内容,并非所有生命周期方法都应该以浅渲染运行。特别是componentDidMount
但是,我注意到当我这样做时
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);
});
测试通过。
那么,我在这里做错了什么还是我理解错了什么?
【问题讨论】:
标签: javascript reactjs unit-testing enzyme