title: Vue with jest - Test with asynchronous call
body: <p>How to make my test wait for the result of my api?
  I'm using vue and jest to test my components.</p>
  
  <p>I want to test the method that writes a client to my database. In my component I have the following method:</p>
  
  <pre><code>methods: {
  
    onSubmitClient(){
  
     axios.post(`urlApi`, this.dados).then(res =&gt; {
  
        return res;
     })
  
    }
  }
  </code></pre>
  
  <p><strong>in my test</strong></p>
  
  <pre><code>describe('login.vue', () =&gt; {
  
    let wrapper
  
    beforeAll(()=&gt;{
  
      wrapper = mount(client, {
        stubs: ['router-link'],
        store,
        data() {
            return {
                dados: {
                    name: 'tes name',
                    city: 'test city'
                },
            };
        }
      })
    })
  
    it('store client', () =&gt; {
  
      res = wrapper.vm.onSubmitLogin()
      console.log(res);
  
    })
  
  })
  </code></pre>
  
  <p>My test does not wait for the API call to complete. I need to wait for the API call to know if the test worked. How can I make my test wait for API return?</p>