小编Bas*_*urk的帖子

如何在 Angular 中模拟 HTTP 请求?

我检查了很多文章和答案,但我似乎没有找到模拟HTTP Requests我的方法的正确方法。我想frontend独立于backend. 这是我拥有的方法类型:

 private getProfile() {
    this.http
      .get('go/profile/get', {withCredentials: true})
      .subscribe((profile: Profile) => {
        this.user.profile = profile;
        this.updateLineMsgs();
      });
  }
Run Code Online (Sandbox Code Playgroud)

有什么建议 ?

unit-testing jasmine karma-jasmine angular angular-test

12
推荐指数
3
解决办法
5万
查看次数