在Angle 4项目中的功能e2e量角器测试中模拟其余调用 [英] Mocking rest calls in functional e2e protractor tests in angular 4 project

查看:82
本文介绍了在Angle 4项目中的功能e2e量角器测试中模拟其余调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个庞大的项目,我们编写了很多测试用例,以涵盖e2e功能测试用例中的许多实际场景用户行为.

We have a huge project and we have written a lot of test cases to cover a lot of real scenario user behavior in our e2e functional test cases.

随着测试的进行,它会进行大量的调用以完成测试用例.当我们在酱料实验室中使用其他浏览器时,它会倍增5-9倍.

As the test goes on, it makes a lot of rest calls to complete the test cases. When we cover different browser in sauce lab it multiplies 5-9 times.

我想要模拟所有其余的调用,这样就不会对实际服务器进行任何真正的调用,但是会在内部对其进行处理.它用于功能性e2e测试,而不是单元测试,因为我们使用茉莉 spyOn 嘲笑了所有单元测试.

What I want is to mock all the rest calls so that there will not be any real calls to the actual server but internally it will be handled. its for functional e2e test not unit test as we mocked all unit tests using jasmine spyOn.

我研究了量角器的 json-server $ httpBackend .子服务器不合适,因为它不能很好地处理应用程序的发布,放置,删除呼叫.如果是$ httpBackend

I have explored json-server and $httpBackend of protractor. son-server did not fit as it does not handles app post, put, delete calls well. in case of $httpBackend

我已经通过这篇文章及其forularular Js应用不是应用程序,还包括有关angularJs的单个REST调用模拟的全部内容,而不是有关所有REST调用的全部信息.

I have gone through this post and its for andularJs app not angular app and also its all about single rest call mocking for angularJs not for all rest calls.

还查看了这个angularjs 针对angularjs的多重模拟,并且对于angularjs也没有角度和外观像这样会更改查询参数的原始rest url.

Also looked this angularjs multi mock for angularjs and its also for angularjs not angular and looks like this changes the original rest url for query parameter.

推荐答案

模拟网络调用.参见这篇文章对应的问题在github上.

Mocking network calls is not supported yet by Protractor for Angular 2+ applications. See this post and the corresponding issue on github.

我个人使用 ng-apimock 插件来模拟对后端的所有网络调用代理.

Personnally, I used ng-apimock plugin to mock all network calls to the backend with a proxy.

它工作得很好并且易于配置.只需在此处

It works really well and is simple to configure. Just follow the configuration for Angular application here

这篇关于在Angle 4项目中的功能e2e量角器测试中模拟其余调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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