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.
const [name] = React.useState(defaultName);
      return (
        <div>
          <p>
            Your name is: <span>{name}</span>
          </p>
        </div>
      );
    }
    const shallowRenderer = createRenderer();
    let result = shallowRenderer.render(
      <SomeComponent defaultName={'Dominic'} />,
    );
    expect(result).toEqual(
      <div>
        <p>
          Your name is: <span>Dominic</span>
        </p>
      </div>,
    );
    result = shallowRenderer.render(
      <SomeComponent defaultName={'Should not use this name'} />,
    );
    expect(result).toEqual(
      <div>
        <p>
          Your name is: <span>Dominic</span>
        </p>
      </div>,