腾讯云
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
工具
TVP
最新优惠活动
文章/答案/技术大牛
搜索
搜索
关闭
发布
精选内容/技术社群/优惠产品,
尽在小程序
立即前往
文章
问答
(995)
视频
沙龙
1
回答
带
自定义
头
的
Angular
-
Unit-test
HttpErrorResponse
(
HttpClientTestingModule
)
、
、
、
、
我有以下代码,我在其中查找出错
的
自定义
标
头
: return this.http.post(loginUrl, credentials) catchError((
httpErrorResponse
:
HttpErrorResponse
) => {let error = new Error('',
ht
浏览 15
提问于2020-02-25
得票数 1
2
回答
角7-在单元测试中捕获
HttpErrorResponse
、
、
、
、
我目前正在学习Range7(没有使用任何以前
的
版本),并且在为服务编写单元测试时遇到了一些我无法修复
的
东西。因此,服务获得
HttpErrorResponse
作为输入,但尝试解析它,就像它是映射函数中
的
常规响应一样。预期
的
行为:我希望map()不会被执行,它应该直接跳入catchError函数。 如何修复(目前而言):
浏览 0
提问于2018-12-04
得票数 11
1
回答
Jasmine:单元测试可观察到
的
http服务错误
、
、
、
我对如何模拟我
的
http服务捕捉到一个可观察到
的
错误感到非常困惑。我已经通读了
angular
文档,但我不明白我将如何构建测试。我想模拟我
的
服务中
的
一个错误,然后检查它是否捕获了一个可观察到
的
错误。import {
HttpErrorResponse
, } from '@
angular
/common/http'; import { TestBed, inject } from '@
angular</
浏览 3
提问于2018-07-03
得票数 7
回答已采纳
1
回答
Angular
11:单元测试HttpInterceptor -无法让catchError在测试中工作
、
、
、
我正在努力完成我
的
HttpInterceptor
的
单元测试。拦截器作为全局错误处理程序工作,只是在catchError(httpResponseError)上触发。下面是拦截器
的
代码:import { HttpClient,
HttpErrorResponse
浏览 14
提问于2021-03-08
得票数 0
回答已采纳
1
回答
试着得到测试单元
的
案例。我想不出怎么去模仿HttpClientRequests,我有点卡住了
、
、
、
、
在试图弄清楚如何为一个项目模拟一个HttpRequest时,我决定我应该为一个简单
的
项目做它,这个项目是我从零开始创建
的
。import { HttpClient,
HttpErrorResponse
, HttpResponse } from '@
angular
/common
浏览 3
提问于2022-03-08
得票数 0
1
回答
StaticInjectorError(DynamicTestModule)[ErrorHandlerInterceptor ->路由器]:
、
、
我已经为我
的
单元测试在我
的
导入中添加了RouterTestingModule。但是它仍然抛出以下错误。我已经附上了我
的
代码作为参考。import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest,
HttpErrorResponse
浏览 2
提问于2019-10-28
得票数 6
1
回答
HttpClient拦截器重试单元测试(预期没有打开请求,发现1)
、
、
、
我有一个简单
的
HttpClient拦截器,它只是重试失败请求
的
次数。现在,我试图为它编写单元测试,但不知怎么
的
,我最终得到了一个未完成
的
请求。/core/testing';import { HT
浏览 2
提问于2019-04-02
得票数 0
回答已采纳
1
回答
如何在ngrx中测试效果?
、
、
、
、
我只想在下面得到我
的
getUser效果。我对下面的例子持开放态度。} from '@ngrx/effects';import { Injectablethis.userService.getUser()), map((result: any) => new
浏览 0
提问于2018-04-25
得票数 0
回答已采纳
1
回答
如何在
Angular
中使用Jasmine对API服务进行正确
的
单元测试抛出错误?
、
、
我是
Angular
和Jasmine框架
的
新手。我已经编写了一些包装HttpClient
的
应用程序接口服务来进行get/post调用,现在我想对get方法进行单元测试,以确保它正确地捕获并抛出正确
的
错误。我
的
api.service.ts看起来像这样:import { HttpClient, HttpParams }如下所示: import {TestBed, i
浏览 0
提问于2018-11-01
得票数 4
1
回答
角度测试- TypeError:无法读取未定义
的
属性'7‘
、
、
、
、
-观察=假 import { Overlay } from '@
angular
/cdk/overlay';import { InjectionToken } from '@
angular
/
浏览 1
提问于2020-06-26
得票数 1
回答已采纳
1
回答
Angular
8:如何使用Jasmine窥探常量/静态属性(服务单元测试)
、
、
import { AppConstants } from 'src/app/constants';import { Injectable } from '@
angular
/core'; @Injectabl
浏览 16
提问于2019-12-16
得票数 1
回答已采纳
2
回答
Angular
Http拦截器列表响应
头
下面的代码不记录来自服务器
的
自定义
标
头
。我是不是遗漏了什么--唯一写出
的
头文件是content-type和content-length。import { Injectable } from '@
angular
/core'; import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest,
HttpErrorResponse
, HttpResponse } from '@
angula
浏览 29
提问于2020-06-05
得票数 3
回答已采纳
1
回答
Angular
单元测试-在HttpInterceptor中测试retryWhen
、
、
、
我正在尝试测试http拦截器中
的
retryWhen操作符,但在多次尝试重复我
的
服务调用时遇到错误:所以我有两个问题。next.handle(req).pipe( .pipe(import { HttpClient } from '@
angular
浏览 12
提问于2019-11-21
得票数 3
2
回答
如何以角度获得响应和/或
自定义
响应标
头
?
、
我找不到一种方法来获得响应和/或
自定义
响应
头
的
角度。我试图捕获并看到
自定义
的
标
头
值或以角表示
的
响应, Ht
浏览 8
提问于2022-11-17
得票数 1
1
回答
‘'Uncaught’Jasmine测试失败
、
、
我有一个功能,搜索巴西邮政编码
的
服务。它工作正常。但这不是我
的
问题。这会使我
的
测试崩溃,并且不会生成任何覆盖率,因为这一点。我已经尝试遵循
angular
文档,在这个中,包括使用asyncError,但没有成功。const ERRORRESPONSE = new
HttpErrorResponse
({ status: 404, statusText: 'service: CadastroService; befor
浏览 9
提问于2020-03-12
得票数 0
2
回答
标
头
未发送角-5
、
、
、
、
希望在标题中发送授权令牌,尝试了两种不同
的
方法,但没有一种方法是针对post请求发送令牌
的
: @Injectable() }是的,截获了这张图像,但结果是:第二种方法非常简单,已经在
angular
2中使用过,但是使用
angular
5时会出错。this.http.post(url, data) .
浏览 1
提问于2018-05-17
得票数 0
1
回答
茉莉花测试失败,未定义为等于
、
我编写了一个角度测试,以测试在服务不可用时返回
的
httpstatus 0代码。在运行测试时,我会得到以下错误。这里有什么可能
的
问题?更新:我更新了单元测试代码,其中包括拦截器类
的
定义,这可能有助于诊断问题。单元测试import {
HttpClientTestingModule
, HttpTestingController} from '@
浏览 1
提问于2019-10-18
得票数 1
回答已采纳
1
回答
如何在测试中模拟
Angular
4.3 httpClient错误响应
、
、
、
、
{
HttpErrorResponse
, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest} from '@
angular
/common/httpimplements HttpInterceptor { private handleError(err:
HttpErrorResponse
下面是我对测试用例auth-interceptor.service.s
浏览 0
提问于2017-09-04
得票数 44
回答已采纳
1
回答
角8:如何模拟配置类(常量&仅在类中
的
静态属性)
、
、
我有一个有以下TypeScript文件
的
角形应用程序:以下是这些文件
的
代码:import { AppConstants } from 'src/Constants'; import { HttpClient,
HttpErrorResponse
} from '@
浏览 0
提问于2019-12-23
得票数 0
1
回答
Angular
8测试服务上
的
路由
、
、
、
、
我正在测试一个Http拦截服务,它使用路由导航到另一个url,当它返回一个错误响应时,我
的
所有测试目前都通过了,因为我没有测试路由本身,但是在我
的
控制台上出现了一个异常。和路由器存根,但看起来我
的
服务只是使用了另一个路由器服务,而不是我
的
.spec提供
的
服务。这是我
的
.spec代码(我因为工作原因删除了url ):import {
浏览 4
提问于2019-12-11
得票数 0
点击加载更多
扫码
添加站长 进交流群
领取专属
10元无门槛券
手把手带您无忧上云
相关
资讯
在Angular中使用JWT认证
Vue、React、Angular 都能用!Tiny Charts,一款跨框架的前端图表神器
倏忽一年:回顾点评前端2019重大事件、趋势
“四大高手”为你的 Vue 应用程序保驾护航
KIWI Design为Quest头显推出RGB Vertical Stand充电支架
热门
标签
更多标签
云服务器
ICP备案
对象存储
腾讯会议
云直播
活动推荐
运营活动
广告
关闭
领券