Angular Protractor e2e Testing

前端 未结 4 1692
半阙折子戏
半阙折子戏 2021-01-02 01:42

I am writing an end-to-end test using Protractor for my Angular application. I can mock httpBackend for unit test but I want to actually call the server and get the JSON re

4条回答
  •  渐次进展
    2021-01-02 02:09

    I'm working through this myself at the moment. The short answer I think is that you set up your application exactly the same as if you were manually testing it yourself - so Protractor is really just a robot user, it has no (well, almost no) access to the internals of your application.

    So, if your application needs a web server (and most do), then you start up that web server, then have protractor connect to your application via the browser and exercise it.

    For my case, I'm aiming to use grunt to call a task that does basic database setup before it starts running my protractor e2e tests - this should give me a known database state.

    For an example of this, I've been writing a tutorial for using Rails 4 with AngularJS, the section on using protractor for e2e testing is not rails-specific and might be useful: http://technpol.wordpress.com/2013/11/16/5-end-to-end-testing/

提交回复
热议问题