See the issue and the test case with original fix in https://github.com/facebook/react/pull/14802.

We'll need to fix it properly, see https://github.com/facebook/react/pull/14802#issuecomment-463277621.
constructor(props, context) {
        super(props, context);
        this.state = {
          foo: 'foo',
        };
      }
      UNSAFE_componentWillMount() {
        this.setState({foo: 'bar'}, () => mockFn());
        this.setState({foo: 'foobar'}, () => mockFn());
      }
      render() {
        return <div>{this.state.foo}</div>;
      }
    }
    shallowRenderer.render(<Component />);
    expect(mockFn).toHaveBeenCalledTimes(2);
    
    const mountedInstance = shallowRenderer.getMountedInstance();
    mountedInstance.setState({foo: 'bar'}, () => mockFn());
    expect(mockFn).toHaveBeenCalledTimes(3);
  });
  it('should call the setState callback even if shouldComponentUpdate = false', done => {
    const mockFn = jest.fn().mockReturnValue(false);
    class Component extends React.Component {