【发布时间】:2016-01-19 15:14:13
【问题描述】:
由于一些基础架构更改(即服务器和 VPN),有时我想以 离线 模式运行我们的应用程序。我已经能够使用 ngMockE2E 来实现这一点,但这似乎是一种全有或全无的方法,这意味着您必须明确地将每个 HTTP 请求从应用程序中设置出来。
有没有办法让它假设除非您明确设置要处理的路由/url,否则它将自动调用通用passThrough() 操作?
目前我正在这样做:
noSrvc = $location.search().hasOwnProperty 'nosrvc'
#
# templates
#
$httpBackend.whenGET /(\.htm|\.html)$/
.passThrough();
#
# session
#
rqst = $httpBackend.whenGET /(api\/users\/current)$/
if !noSrvc then rqst.passThrough() else rqst.respond {"user":{
# doing something similar for every single service call in the app... gets tedious after about 3-4
我读过的关于该主题的大部分内容都涉及单元测试,并且没有真正解决隐含的传递,除非另有说明。
【问题讨论】:
标签: angularjs http coffeescript ngmocke2e