You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When shallow rendering a component using lifecycleExperimental: true, it seems that it's props are not updated if it's shouldComponentUpdate()-method returns false. Since the props are updated in production and when using standard shallow rendering, I'm guessing that this would be the desired behavior.
import React from 'react';
import chai from 'chai';
import { shallow } from 'enzyme';
class MyDummyComponent extends React.Component {
shouldComponentUpdate() {
return false;
}
render() {
return (<div>hello world.</div>)
}
}
describe('<MyDummyComponent/>', function () {
it('fails to update props with lifecycleExperimental: true', function () {
let props = {
foo: 'bar'
}
const wrapper = shallow(<MyDummyComponent {...props} />, { lifecycleExperimental: true });
chai.expect(wrapper.instance().props.foo).to.equal('bar');
props.foo = 'baz';
wrapper.setProps(props);
// fails when shouldComponentUpdate returns false, succeeds otherwise
chai.expect(wrapper.instance().props.foo).to.equal('baz');
});
it('updates props with "normal" shallow rendering', function () {
let props = {
foo: 'bar'
}
const wrapper = shallow(<MyDummyComponent {...props} />);
chai.expect(wrapper.instance().props.foo).to.equal('bar');
props.foo = 'baz';
wrapper.setProps(props);
chai.expect(wrapper.instance().props.foo).to.equal('baz');
});
});
I am using React 15.4.2 & Enzyme 2.7.1.
The text was updated successfully, but these errors were encountered:
When shallow rendering a component using lifecycleExperimental: true, it seems that it's props are not updated if it's shouldComponentUpdate()-method returns false. Since the props are updated in production and when using standard shallow rendering, I'm guessing that this would be the desired behavior.
I am using React 15.4.2 & Enzyme 2.7.1.
The text was updated successfully, but these errors were encountered: