# How to mock login in cypress

**URL:** <https://devforum.okta.com/t/how-to-mock-login-in-cypress/13775>\
**Category:** Questions\
**Created:** [April 13, 2021, 3:09pm UTC](https://devforum.okta.com/t/how-to-mock-login-in-cypress/13775 "2021-04-13T15:09:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pranav\_maheshwari](https://avatars.discourse-cdn.com/v4/letter/p/cdc98d/32.png) [@pranav\_maheshwari](https://devforum.okta.com/u/pranav_maheshwari)\
**Post date:** [April 13, 2021, 3:09pm UTC](https://devforum.okta.com/t/how-to-mock-login-in-cypress/13775/1 "2021-04-13T15:09:51Z")

</div>

We are using @okta/okta-auth-js client and I want to mock the login (without actual credentials) for cypress. But I’m getting error at token.getWithoutPrompt.

---

<div class="post-metadata">

**Author:** ![mraible](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/mraible/32/37_2.png) [@mraible](https://devforum.okta.com/u/mraible)\
**Post date:** [April 13, 2021, 3:23pm UTC](https://devforum.okta.com/t/how-to-mock-login-in-cypress/13775/2 "2021-04-13T15:23:53Z")

</div>

We’ve successfully implemented Okta login in the [JHipster](https://www.jhipster.tech) project. If you generate an app with OAuth 2.0 / OIDC for authentication, it’ll create e2e tests for you that work with Keycloak. They also work with Okta, but we did have to integrate Puppeteer too because Okta uses JS on their login form, whereas Keycloak does not.

This PR shows some of the code we added to make things work. [https://github.com/jhipster/generator-jhipster/pull/13611](https://github.com/jhipster/generator-jhipster/pull/13611)

---

<div class="post-metadata">

**Author:** ![pranav\_maheshwari](https://avatars.discourse-cdn.com/v4/letter/p/cdc98d/32.png) [@pranav\_maheshwari](https://devforum.okta.com/u/pranav_maheshwari)\
**Post date:** [April 14, 2021, 7:14am UTC](https://devforum.okta.com/t/how-to-mock-login-in-cypress/13775/3 "2021-04-14T07:14:22Z")

</div>

@mraible I don’t want to actually login, I just want to mock the login for my e2e testing so that they can run without internet.

---

<div class="post-metadata">

**Author:** ![mraible](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/mraible/32/37_2.png) [@mraible](https://devforum.okta.com/u/mraible)\
**Post date:** [April 14, 2021, 12:56pm UTC](https://devforum.okta.com/t/how-to-mock-login-in-cypress/13775/4 "2021-04-14T12:56:27Z")

</div>

Oh. I’m sorry, but I don’t know how to do that.

---

<div class="post-metadata">

**Author:** ![pranav\_maheshwari](https://avatars.discourse-cdn.com/v4/letter/p/cdc98d/32.png) [@pranav\_maheshwari](https://devforum.okta.com/u/pranav_maheshwari)\
**Post date:** [April 14, 2021, 3:43pm UTC](https://devforum.okta.com/t/how-to-mock-login-in-cypress/13775/5 "2021-04-14T15:43:04Z")

</div>

@mraible Can anyone from okta team help me out?

---

<div class="post-metadata">

**Author:** ![mraible](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/mraible/32/37_2.png) [@mraible](https://devforum.okta.com/u/mraible)\
**Post date:** [April 15, 2021, 5:34am UTC](https://devforum.okta.com/t/how-to-mock-login-in-cypress/13775/6 "2021-04-15T05:34:25Z")

</div>

There’s an [open issue on GitHub](https://github.com/okta/okta-auth-js/issues/584) with someone trying to do something similar to what you want. I’d suggest joining that conversation.

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 6, 2024, 11:30pm UTC](https://devforum.okta.com/t/how-to-mock-login-in-cypress/13775/7 "2024-02-06T23:30:50Z")

</div>


