{"action":"closed","issue":{"url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/380","repository_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X","labels_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/380/labels{/name}","comments_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/380/comments","events_url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/issues/380/events","html_url":"https://github.com/IMA-WorldHealth/bhima-2.X/issues/380","id":153134826,"number":380,"title":"Use `browser.setLocation()` instead of `browser.get()` for e2e tests","user":{"login":"jniles","id":896472,"avatar_url":"https://avatars.githubusercontent.com/u/896472?v=3","gravatar_id":"","url":"https://api.github.com/users/jniles","html_url":"https://github.com/jniles","followers_url":"https://api.github.com/users/jniles/followers","following_url":"https://api.github.com/users/jniles/following{/other_user}","gists_url":"https://api.github.com/users/jniles/gists{/gist_id}","starred_url":"https://api.github.com/users/jniles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jniles/subscriptions","organizations_url":"https://api.github.com/users/jniles/orgs","repos_url":"https://api.github.com/users/jniles/repos","events_url":"https://api.github.com/users/jniles/events{/privacy}","received_events_url":"https://api.github.com/users/jniles/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/labels/best%20practice","name":"best practice","color":"009800"},{"url":"https://api.github.com/repos/IMA-WorldHealth/bhima-2.X/labels/refactor","name":"refactor","color":"fbca04"}],"state":"closed","locked":false,"assignee":{"login":"jniles","id":896472,"avatar_url":"https://avatars.githubusercontent.com/u/896472?v=3","gravatar_id":"","url":"https://api.github.com/users/jniles","html_url":"https://github.com/jniles","followers_url":"https://api.github.com/users/jniles/followers","following_url":"https://api.github.com/users/jniles/following{/other_user}","gists_url":"https://api.github.com/users/jniles/gists{/gist_id}","starred_url":"https://api.github.com/users/jniles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jniles/subscriptions","organizations_url":"https://api.github.com/users/jniles/orgs","repos_url":"https://api.github.com/users/jniles/repos","events_url":"https://api.github.com/users/jniles/events{/privacy}","received_events_url":"https://api.github.com/users/jniles/received_events","type":"User","site_admin":false},"milestone":null,"comments":0,"created_at":"2016-05-04T23:02:13Z","updated_at":"2016-05-16T08:45:21Z","closed_at":"2016-05-16T08:45:21Z","body":"Our end to end test structure recently got a speedup in #351 by replacing `beforeEach()` with `before()`, ensuring the browser only loads the module at the beginning of the test, and does not refresh the module within the test suite.\r\n\r\nNow, we can optimize the actual function called in the `before()` call.  Previously, we used the following code:\r\n```js\r\nbefore(() => browser.get('#/some/route'));\r\n```\r\nThis works fine, but is inefficient.  According to the protractor API documentation for [browser.get()](http://angular.github.io/protractor/#/api?view=Protractor.prototype.get), this navigates and loads the target page.  From our testing experience, this completely reloads the page, similar to `browser.refresh()`.\r\n\r\nA more natural way to navigate is by changing the `$location` URL, as Angular does.  This is more efficient since it does not require the browser to refresh the page.  It also is reflective of how our application behaves.  Protractor exposes a method [browser.setLocation()](http://angular.github.io/protractor/#/api?view=Protractor.prototype.setLocation) that performs navigation based on the URL hash.   We can therefore change all our `before()` functions to:\r\n```js\r\nbefore(() => browser.setLocation('some/route'));\r\n```\r\nThis has already been demonstrated in an upcoming pull request [here](https://github.com/IMA-WorldHealth/bhima-2.X/pull/378/files#diff-225c1021c869b5120019692bf2f475aaR22).  If we apply this across all our tests, we will likely receive another performance boost. "}}