javascript - Simulate connection errors -


we've been using protractor end-to-end testing while.

now trying cover several corner cases, involve modifying response api endpoint requests - using protractor-http-mock provides easy-to-use way replace http responses pre-defined mocks.

but, if want test situation when sudden connection loss happens? our options in case?

in other words, want achieve case when requests specific endpoints produce network connection error , see how our application react.


i'm open suggestions, thinking of following strategies:

  • see if there third-party nodejs libraries similar protractor-http-mock
  • mock $http angularjs service
  • fire proxy , somehow control during tests (grunt-connect-proxy looks pretty mature though i'm not sure if possible dynamically change behavior of proxy spec spec)
  • control on browser level - e.g. network throttling google chrome feature (though i'm pretty sure selenium cannot control, network throttling chrome , selenium) (browser addon/extension?)

i hope helps define best way implement mocks.

the project explains general idea, there semantics , translation problems readme.md, i'll working on please patient. please forget english/misspelling let me known of correction

i working on demo project of how implement protractor + cucumberjs + sugar-step . right contains very simple angular app , 3 e2e test.

the demo working, unfinished yet, still need features think useful e2e testing.

  • the first test check service against default service (dev environment mock)
  • the second test check service request returns error status code 404
  • the third test check service request returns error status code 500

how can set different mock responses each scenario?

  • using cucumber's around feature, can used inject angular.module('mock-service-response-x',fn...) before feature or scenario, , remove after feature or scenario runs

what can tested way?

  • any kind of scenarios, responses extreme delays, response status code, response special data test particular scenarios otherwise impossible/hard obtain normal back-end service, data inconsistency on back-end

why implement ui-mocks in angularjs , not proxy?

  • ui control, (of course depending of particular needs) using angular can things like: disable nganimations or jquery animations entirely, mock local browser date, emulate behaviors depends on date in automatically.

  • cost, (depending of project) cost of implement local proxy web services on every dev environment can expensive (in hardware or effort or hours of implementation).

  • dependency, if dev teams working in parallel, it's more depending each-other, if ui team working in feature depends on x web service, knowing implementation specs ui team can create simple mocks continue work making more probable deliver on time of hole project

all arguments depends of project working on, , doesn't mean @ best solution, i'm more in favor of keep project layers independent each other, , able release new feature in 1 layer no matter if other layer delayed in own new features.

to reads this, comment, correction or suggestion more welcome


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -