AngularJS量角器E2E嘲讽 [英] AngularJS Protractor E2E Mocking

查看:134
本文介绍了AngularJS量角器E2E嘲讽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个角SPA从节点后端检索数据。
由于节点项目完全覆盖有测试中,我想嘲笑角HTTP调用。
(我不想开始对一般functional- /烟雾测试,感谢讨论)。

I have an Angular SPA retrieving its data from a node backend. Since the node project is fully covered with tests I want to mock the Angular HTTP calls. (I do not want to start a discussion about functional-/smoke-tests in general, thanks).

我想什么已经是s.th.像这样

What I'd like to have is s.th. like this

Api = $injector.get('Api');
sinon.mock(Api, 'getSomethingFromServer').andRespondWith({foo: 'bar'})
assert(Api.getSomethingFromServer.wasCalledOnce);

但不管我怎么不能找到一个很好的解决方案。
我就发现了同样的问题几个职位。
对于例如这一个

由于量角器是改变了很多,经常,我只是想在这里问的,所以如果的任何的发现嘲讽的HTTP请求妥善解决。

Since protractor is changing a lot and frequently, I just like to ask here on SO if anyone found a proper solution for mocking the HTTP requests.

推荐答案

我同意previous答案。到量角器频繁更改答案是完全地从系统中去相关测试的后端,无论是模拟,存根,还是假的。

I agree with previous answer. An answer to frequent change of Protractor is to completly decorrelate the backend from the system under test, no matter if it is mock, stub, or fake.

的困难是保持与真正后端很强的连贯性,但它没有说,这是不是试图维持与角嘲讽的总是在不断变化的方式更多的开销。

The difficulty is to maintain a strong coherence with the real backend, but it is not said that it is more overhead than trying to maintain an always changing way of mocking with angular.

这篇关于AngularJS量角器E2E嘲讽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆