diff --git a/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx b/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx index 4418fe35a..74cbaf526 100644 --- a/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx +++ b/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx @@ -5084,6 +5084,36 @@ describe('shallow', () => { expect(spy).to.have.property('callCount', 0); }); + it('should be able to call `componentDidMount` directly when disableLifecycleMethods is true', () => { + class Table extends React.Component { + render() { + return (); + } + } + + class MyComponent extends React.Component { + constructor(props) { + super(props); + this.state = { + showTable: false, + }; + } + + componentDidMount() { + this.setState({ showTable: true }); + } + + render() { + const { showTable } = this.state; + return ({showTable ?
: null}); + } + } + const wrapper = shallow(, { disableLifecycleMethods: true }); + expect(wrapper.find(Table).length).to.equal(0); + wrapper.instance().componentDidMount(); + expect(wrapper.find(Table).length).to.equal(1); + }); + it('should call shouldComponentUpdate when disableLifecycleMethods flag is true', () => { const spy = sinon.spy(); class Foo extends React.Component {