在角度5中对异步等待功能进行单元测试

时间:2019-05-06 08:59:52

标签: angular unit-testing async-await

我需要知道如何编写与Angular 5中的异步/等待功能(与STT服务的后台服务连接)的单元测试。有人可以帮忙吗?

async listen(){
 let data = await fetch('http://localhost:13005/getGoogleText', {
      method: 'GET'
    })
    .then(function(response) {
      if (response.ok) {
      return response.json();
      }
    })
    .then(response => {
      return response;
    })
    .catch(error => {
      return (error);
      console.error(error);
    });
}

0 个答案:

没有答案