In my tests, I would like to block the main thread until one of my components completes its life methods, after componentDidUpdate(), after I raise an event that forces it to add child components to itself. How can i do this?
Something like that:
describe('my <Component />', () => {
it('should do what I want when its button is clicked twice', () => {
const wrapper = mount(<Component />);
const button = wrapper.find('button');
button.simulate('click', mockEvent);
wrapper.instance().askReactToBlockUntilTheComponentIsFinishedUpdating();
button.simulate('click', mockEvent);
expect(whatIWant()).to.be.true;
});
});
(I want to do this because right now I am getting this warning:
Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op.
, , , React, , , button.simulate('click') , React , . , - .)