Angular E2E Protractor testing : error to join API from testing session

19 Views Asked by At

For an Angular application, I'm creating E2E Tests from Protractor and Jasmine.

All feel good except the externals API calls. For example, if I try to test and simulate login, the form will correctly be complete but when I submit it thanks to a click, the API Call is in error with some CORS errors.

The CORS errors is not here when I run it outside testing session. All my tests are run in local computer and with a firefox browser. However, I don't understand why I couldn't join my API's (DRF API on a local docker container). I confirm that the API allows all CORS origins and contains correct headers.

Do you have any idea to fix this problem and to test all the submit login form ?

For my test :

  login(username: string, password: string): void {
    this.navigateToLogin();
    browser.wait(this.getInputUsername().sendKeys(username), 1000);
    browser.wait(this.getInputPassword().sendKeys(password));
    // Wait to show what happens for the demo.
    browser.sleep(500);
    const signInButton = this.getLoginSubmitButton();
    browser.wait(
      signInButton.isDisplayed(),
      1000,
      'sign in button not visible'
    );
    signInButton.click();
    browser.sleep(50000);
  }
0

There are 0 best solutions below