Reputation: 811
I'm trying to use cypress to cover our dev-server by a set of complete e2e
tests.
We have a requirement to lock our dev environment under basic http authentication so nobody couldn't access it without proper credentials (both client and api).
When I'm trying to run Cypress tests they fail because of that. Server (nginx) just responds with 401 http-code.
I tried to pass credentials in url like 'user:[email protected]', and it partially works: cypress is able to reach frontend on domain.com, but it's still unable to send any requests to our backend (api.domain.com) from within the page (using fetch
) - probably because of different subdomain or something.
I'm looking for a way for forcing it to use those credentials on all requests on a domain or any other workaround that may help me run the tests.
Thanks!
Upvotes: 0
Views: 2132
Reputation: 4659
This might not be an auth issue. fetch
does not work with cypress. See https://github.com/cypress-io/cypress/issues/687
A workaround for it is to put this into your support/index.js file:
Cypress.on("window:before:load", win => {
win.fetch = null;
});
Upvotes: 1