title: mockRejectedValueOnce is not a function
body: <p>Writing test for a functional component that uses a service. Trying to test scenario when service returns error. But getting error "mockRejectedValueOnce is not a function". Can someone please help.</p>
  
  <p>Test scenarios where by data is received from service passes, so not missing a dependency.</p>
  
  <pre><code>import {render, cleanup, wait} from '@testing-library/react';
  import '@testing-library/jest-dom/extend-expect'
  import ChatList from './../components/ChatList';
  import getMessages from "./../service";
  
  jest.mock("./../service");
  
  describe("ChatList renders chat",()=&gt;{
  
      it("renders error when error occurs during data fetch",()=&gt;{
          getMessages.mockRejectedValueOnce('an error');
          const {getByTestId, queryByTestId} = render(&lt;ChatList/&gt;);
          expect(getMessages).toHaveBeenCalledTimes(1);
          wait(() =&gt; {
              expect(queryByTestId("messages-list")).toBeNull();
              expect(getByTestId("error-wrapper")).toBeInTheDocument();
          });
      });
  
  });
  </code></pre>
  
  <p>message service looks like below:</p>
  
  <pre><code>export default function getMessages() {
      return new Promise(function(resolve, reject) {
         //array of messgaes
  
      });
  };
  </code></pre>
  
  <p>Actual results:  </p>
  
  <pre><code>TypeError: _service2.default.mockRejectedValueOnce is not a function
  
        at Object.it (src/_tests_/ChatList.test.js:48:80)
        at process._tickCallback (internal/process/next_tick.js:68:7)
  </code></pre>