“模拟"带有 Protractor、Cucumber 和 Chai 的后端 http 响应 [英] "Mock" a backend http response with Protractor, Cucumber and Chai

查看:20
本文介绍了“模拟"带有 Protractor、Cucumber 和 Chai 的后端 http 响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先我将解释我的目标:我有一个应用程序分为几个模块.在这种情况下,我只想测试我的 ui 模块.我有一些对后端的调用,我想模拟响应或只是更改一些模型的值.我认为您无法更改模型的值,因此我正在尝试模拟后端.

我有一个模型文档",当我按下搜索按钮时,它会从其他模块的后端获取数据.示例:

我从黄瓜和嘲笑开始,如果这个问题如此笼统,请原谅我.

解决方案

这是最终的解决方案.经过2天的研究,我一切正常.https://docs.google.com/document/d/1beEchJyQejSLajJo1zqOd0gdUtaAESIqIkBXPzOs_IU/edit?usp=分享

在尝试使用此框架"进行测试之后.我可以说 chai 是没有必要的.只需使用 Protractor-cucumber-framework 和 cucumber 包就足够了

First of all i will explain my goal : I have an app divided into several modules. In this case I just want to test my ui-module. I have some calls to the back-end there and i want to simulate the response or just change some models' values. I think you can not change the value of a model, so i am trying to simulate the back-end.

I have a model 'documents' that when i press a search button, it get data from the back-end in other module. Example: http://localhost:8080/search-module/API/search I want to test that without the backend.

I have tried with "httpbackend" but i can not get it going. Also i have tried "protractor-http-mock" and neither

Here is all my code for now:

I am starting with cucumber and mocking so forgive me if this question is so general.

解决方案

Here is the final solution for this. After 2 days of research I have everything working. https://docs.google.com/document/d/1beEchJyQejSLajJo1zqOd0gdUtaAESIqIkBXPzOs_IU/edit?usp=sharing

After try to test something with this "framework". I can say chai is not necessary. Just with Protractor-cucumber-framework and cucumber package is enough

这篇关于“模拟"带有 Protractor、Cucumber 和 Chai 的后端 http 响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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