4
지금까지 여러 해답을 읽은 필자의 이해와 모든 라이프 사이클 메소드가 얕은 렌더링으로 실행되는 것은 아닙니다. 특히 componentDidMount
componentDidMount는 Enzyme에서 얕은 렌더링으로 실행해야합니까?
그러나, 나는
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);
});
을 수행 할 때 테스트를 통과 한 것을 알 수 있습니다.
그래서 내가 여기 뭔가 잘못하고있는 중이거나 잘못 이해 한 것입니까?
, 덕분에이 모든 라이프 사이클 메소드를 실행하는 것을 의미한다.. 이제는 "얕은"렌더링을 사용하고 있습니까? 저는 각 렌더링 유형에서 어떤 라이프 사이클 메소드가 실행되는지 PR을 열어 볼 수 있다고 생각합니다. –
@DimitrisKaragiannis 저는 그렇게 생각합니다. 각 렌더주기를 신속하게 테스트 할 수 있습니다 .. –
저는 3.3.0 버전에서 얕은 렌더링 동안 componentDidMount가 호출되지 않지만 componentWillMount는 어떤 일이 일어나는지 알 수 있습니다. @DimitrisKaragiannis이 작업을 수행 했습니까? –