0

I have a problem with Cypress. I have localhost fired up and in all browsers (Chrome, Firefox, Opera) my app opens. On the other hand, in Cypress when enabling tests (Chrome, Firefox, Electron), I have a problem with the backend. The login page opens, but when I enter my login details, I get an error related to the backend.

Cypress version 12.14.0

Console

Cypress

I tried doing downgrades to lower versions of Cypress, I uninstalled and installed NPM on the frontend and backend.

In Firefox, it shows an error like this "Cross-Origin Request Blocked: same-origin rules prevent reading of remote resource (Reason: CORS request failed). Status code: (null)". In Chrome, it only shows such an error "TypeError: NetworkError when trying to retrieve a resource.". But as I say, in a "normal" browser everything works ok. Only when firing up the tests there is an error.

chromeWebSecurity is set to false of course.

Things I have already tried:

  • Tested to see if using a Incognito instance was the issue.
  • Removed frontend project, removed Cypress folders including cache folder and pulled project down again.
  • Tested if it was only relating to Chromium browsers. Issue exists in Firefox also.
  • Set flags in the cypress.json folder for chromeWebSecurity to false.
  • Tried different login methods using the UI and also using cy.session
  • Tried pausing the Test Runner, manually opened a new tab, enter localhost, tried to log in, the same error
  • A colleague also tried to fire it up on another laptop In the end, I did a laptop format (Macbook Air 2015) because it needed a refresh anyway
Johnny
  • 1
  • 2
  • 1
    Please share more details, like the error message you are facing – Nico Haase Jun 13 '23 at 12:30
  • In Firefox, it shows an error like this "Cross-Origin Request Blocked: same-origin rules prevent reading of remote resource (Reason: CORS request failed). Status code: (null)". In Chrome, it only shows such an error "TypeError: NetworkError when trying to retrieve a resource.". But as I say, in a "normal" browser everything works ok. Only when firing up the tests there is an error. – Johnny Jun 13 '23 at 13:20
  • did you try to set setting { "chromeWebSecurity": false } in your 'cypress.json' ? this link might be helpful how to avoid CORS errors-> https://stackoverflow.com/questions/50495996/cypress-e2e-testing-how-to-get-around-cross-origin-errors – Murat Ishenbaev Jun 13 '23 at 14:51
  • Please add **all** clarification to your question by editing it – Nico Haase Jun 13 '23 at 14:52
  • chromeWebSecurity is set to false of course. I updated my post. – Johnny Jun 14 '23 at 11:04
  • I just updated things I have already tried – Johnny Jun 19 '23 at 11:01

0 Answers0