How can I bypass Keycloak for Cypress tests

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

How does a user/account initially authenticate to your app? Is it something resembling the account registration in Keycloak?

Mocking all that stuff can be a neverending story.
For this reason, but for the Java ecosystem, I startet 5 years ago the Keycloak Testcontainers extension, to have a dedicated Keycloak server in my tests during execution.
Don‘t know if it is somehow possible to use this with Cypress or if there‘s a JS equivalent.