view doesn't load when I mock backend

匆匆过客 提交于 2019-12-04 16:57:45

To be sure that your mock is loaded, you can add console.log inside, and, in your protractor test add :

browser.manage().logs().get('browser').then(function(browserLog) {
    console.log('log: ' + require('util').inspect(browserLog));
});

In order to output browser logs in your protractor console (after your browser.get).

It seems I didn't provide sufficient information. I left out some code that I thought was irrelevant with intent to not overwhelm you, but as it turned out it was a stumbling block.

browser.get 'http://localhost:9000/#/'
element By.model 'email'
  .sendKeys 'dima@mail'
element By.model 'password'
  .sendKeys '123456'
element By.cssContainingText 'form[name=login] button', 'Войти'
  .click()

This code is responsible for logging user in, I need it here because unauthorized users aren't allowed to see the view I wanted to test. I thought I made sure all requests make it through, but of course I forgot that my login request is a POST request. So problem was solved simply by adding

$httpBackend.whenPOST /.*/
      .passThrough()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!