title: Return different data in different mock API calls in jest
body: <p>I am starting to learn more about testing React components using Jest and testing-library.
  I've used mock API to return user data and render it in my test and want to return <code>user_active = true</code> in the firs API call and <code>user_active = false</code> in the second API call.</p>
  <p>this is my code in <strong>mocks</strong> folder to mock getUsers API:</p>
  <pre><code>&quot;use strict&quot;;
  module.exports = {
    getUsers: () =&gt; {
      return Promise.resolve({
        data: {
          id: 27,
          full_name: &quot;john doe&quot;,
          username: &quot;jhon&quot;,
          is_active: true,
        },
      });
    },
  }
  </code></pre>
  <p>this is my component and user info is an object that contain (id, full_name, username, is_active):</p>
  <pre><code>  class Users extends Component {
        constructor(props) {
          super(props);
          this.state = {
            userInfo: null,
          };
        }
  
  
    getUsers = () =&gt; {
      const token = this.props.token;
      myAPI.getUsers(token)
        .then((res) =&gt; {
          this.setState({
            data: res.data,
            error: null,
          });
        })
        .catch((error) =&gt; {
          this.setState({
            error: error,
            data: [],
          });
        });
    };
  
    refreshList = () =&gt; {
       this.getUsers();
    };
  
    render() {
      return (
        &lt;div&gt;
         &lt;a data-testid=&quot;refresh-button&quot; onClick = {this.refreshList}&gt;load user data &lt;/a&gt;
         &lt;span&gt; {this.state.userInfo.username}&lt;/span&gt;
         &lt;span&gt; {this.state.userInfo.is_active}&lt;/span&gt;
        &lt;/div&gt;
       )
      
    }
  
  
  }
  </code></pre>
  <p>and this is my test:</p>
  <pre><code>import React from &quot;react&quot;;
  import { render } from &quot;@testing-library/react&quot;;
  import &quot;@testing-library/jest-dom/extend-expect&quot;;
  jest.mock(&quot;../MyApi&quot;);
  import Users from &quot;./index&quot;;
  
  
    test(&quot;load users twice&quot;, async () =&gt; {
    let baseDom = render(&lt;Users/&gt;);//first API call  
    expect(await baseDom.findByText(&quot;true&quot;)).toBeInTheDocument();
    fireEvent.click(await baseDom.findByTestId(&quot;refresh-button&quot;)); //to second api call
    expect(await baseDom.findByText(&quot;false&quot;)).toBeInTheDocument();
  });
  </code></pre>
  <p>How can I return different data in first/second API call?</p>