3

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: enter image description here enter image description here

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

rpy
  • 3,953
  • 2
  • 20
  • 31
vict
  • 212
  • 1
  • 3
  • 14

2 Answers2

1

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

vict
  • 212
  • 1
  • 3
  • 14
  • Warning for any visitors trying to find a way to mock an angular2+ app, httpbackend just uses the addMockModule to use the angular object to mock objects. This does only work for angularjs – SomeOne_1 May 29 '20 at 14:09
0

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 |
Dave McNulla
  • 2,006
  • 16
  • 23
  • i forgot about my app is running in Angularjs, not in ruby. – vict May 26 '16 at 08:11
  • I seemed like it was JS. For my simulator, you run it separately so it is independent of whatever what code language you are using. The other two only support ruby. – Dave McNulla May 26 '16 at 15:25
  • thanks you @Dave but i have just resolved it. I will write and answer for people with the same problem – vict May 26 '16 at 15:37