title: how to mock AWS library in jest
body: <p>I am using signIn method from 'aws-amplify' library. I am not able to call signIn method from this library while running test case in jest.</p>
  
  <p>Code:</p>
  
  <pre><code>import { Auth } from "aws-amplify"; // import statement
  
  //code for function
  handleSubmit = async event =&gt; {
    event.preventDefault();
    this.setState({ isLoading: true });
    try {
      await Auth.signIn(this.state.username, this.state.password);
      this.props.history.push("/dashboard");
    } catch (e) {
      this.setState({ isLoading: false });
    }
  }
  </code></pre>
  
  <p>Test file:</p>
  
  <pre><code>it('calls event handler; "handleSubmit"', async()  =&gt; {   
      const componentInstance = Wrapper2.dive().instance();
  
      componentInstance.setState({
          isLoading : false,
          username : "demo",
          password : "demo"
      })
      const event = {
          preventDefault : () =&gt; {}
      };
      await componentInstance.handleSubmit(event);
      expect(componentInstance.state.isLoading).toEqual(true); 
  });
  </code></pre>
  
  <p>While running above test case, It always goes into catch section of handleSubmit() function.</p>
  
  <p>How can I achieve calling signIn method from 'aws-amplify' library and testing positive/negative scenarios ?</p>
  
  <p>Guide me, Thanks in advance.</p>