We’ve recently switched from using Auth0 to Keycloak as a JWT-based authentication source for our application. All’s moved over fine, with the exception of the E2E/acceptance tests written in Cypress.
I wondered what the recommended way to handle authentication in tests was? I’ve tried cypress-keycloak
as a library (from NPM) but this seems to rely on a Keycloak instance being in place, which will not be the case when the tests run. I also tried cypress-keycloak-commands
, and whilst the kcFakeLogin
method has been tantilising, I just can’t get the thing to work as intended.
Now, I can totally understand that authentication isn’t meant to be easy to ‘fake’ for fairly obvious reasons, but is there something that I’ve been missing or doing wrong here? I feel like I must be approaching it somehow in the wrong way, as there seems to be very little information out there, but don’t know what the right way is!
Best wishes,
Algy Taylor