“Mock” a backend http response with Protractor, Cucumber and Chai

霸气de小男生 提交于 2019-12-04 13:10:49

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

I've seen Pinch Hitter and WebMock used for that in ruby.

If you want an out-of-process server, I have a simulator that will let you POST the next GET if that helps.

Scenario Outline: Request a special service reply for a particular path
  When I request a GET for "<response>" from "<path>"
  And I send a GET to "<path>"
  Then I receive "<response>"
Examples:
  | path   | response                        |
  | /test1 | col1,col1\nr1c1,r1c2\nr2c1,r2c2 |

@service.get
Scenario Outline: Request a service reply from a preset file
  When I have a file "<name>" with "<contents>"
  And I send a GET to "<name>"
  Then I receive "<contents>"
Examples:
  | name | contents                                |
  | temp | One fish, two fish, red fish, blue fish |
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!