https://cypress.io logo
Hi All, I need a help with cy.Visit() using basic ...
# e2e-testing
k
Hi All, I need a help with cy.Visit() using basic auth. For some reason both methods mentioned in documentation ( direct pass creds via url, adding params to visit ) and also adding header with authorisation : "basic tokenhash" are not working. I've checked all these methods on some other test example sites which I was able to find (e.g. https://the-internet.herokuapp.com/basic_auth admin:admin Basic YWRtaW46YWRtaW4=) they all work fine. So I suspect there is something special with our Angular app. We are building app based on angular11 and using basicAuth from 'express-basic-auth' and we have prerender. Year ago I was using simple url pass ( https:// user:pass @ domain.site ) and it was working fine. Now not using any auth - just returns 401 immediately and using any of mentioned methods fails after 30 seconds timeout( Error: ESOCKETTIMEDOUT) . I'm stuck with this, and need an advice.
f
Hard to say what could be the issue without being able to see the site. If you're able to authenticate via the UI, you can use that as a workaround.
cy.session()
will allow you to cache those cookies and use them in other specs. Not as speedy as if you did it all headlessly, but better than nothing