# End-to-End Testing with Cypress and Auth0

**URL:** <https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082>\
**Category:** Get Help\
**Created:** [December 14, 2018, 1:35pm UTC](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082 "2018-12-14T13:35:04Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [September 30, 2019, 7:09am UTC](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082/22 "2019-09-30T07:09:02Z")

</div>

Hey there @Ali-Doustkani!

It would be great actually if you can share that feedback along with the context with repo maintainers by raising a GitHub issue in the repo. Thank you!

---

<div class="post-metadata">

**Author:** ![corruptedmonk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/corruptedmonk/32/15605_2.png) [@corruptedmonk](https://community.auth0.com/u/corruptedmonk)\
**Post date:** [October 3, 2019, 8:50am UTC](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082/23 "2019-10-03T08:50:43Z")

</div>

@Ali-Doustkani  
Check out my solution in the comment above.  
This is the solution for Auth0-spa-js package for now.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [October 3, 2019, 8:56am UTC](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082/24 "2019-10-03T08:56:34Z")

</div>

Thanks a lot for sharing that with the rest of community @corruptedmonk!

---

<div class="post-metadata">

**Author:** ![Ali-Doustkani](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ali-doustkani/32/14378_2.png) [@Ali-Doustkani](https://community.auth0.com/u/Ali-Doustkani)\
**Post date:** [October 3, 2019, 9:13am UTC](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082/25 "2019-10-03T09:13:30Z")

</div>

I finally did it in your way. Thanks for the comment!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [October 3, 2019, 9:19am UTC](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082/26 "2019-10-03T09:19:05Z")

</div>

Glad you have it working @Ali-Doustkani!

---

<div class="post-metadata">

**Author:** ![bruno.krebs](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bruno.krebs/32/4382_2.png) [@bruno.krebs](https://community.auth0.com/u/bruno.krebs)\
**Post date:** [October 18, 2019, 9:23am UTC](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082/27 "2019-10-18T09:23:59Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [December 2, 2019, 10:05am UTC](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082/28 "2019-12-02T10:05:24Z")

</div>



---

<div class="post-metadata">

**Author:** ![jonathan.dudley](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jonathan.dudley/32/15791_2.png) [@jonathan.dudley](https://community.auth0.com/u/jonathan.dudley)\
**Post date:** [December 1, 2019, 11:37pm UTC](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082/29 "2019-12-01T23:37:35Z")

</div>

Hi @konrad.sopala. Essentially how can we achieve similar to the result in this article using the new auth0 library?

> **[End-to-End Testing with Cypress and Auth0](https://auth0.com/blog/amp/end-to-end-testing-with-cypress-and-auth0/#Writing-tests-using-Cypress-Login-Command)**
>
> Learn how to programmatically authenticate against Auth0 in your Cypress tests in a manner that adheres to both Cypress and Auth0 best pr...

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [December 2, 2019, 10:07am UTC](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082/30 "2019-12-02T10:07:01Z")

</div>

Hey there @jonathan.dudley!

I moved your reply here as it seems more appropriate. Can you specify your question a little bit more as I’m not sure what you mean 🙂 Thank you!

---

<div class="post-metadata">

**Author:** ![jonathan.dudley](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jonathan.dudley/32/15791_2.png) [@jonathan.dudley](https://community.auth0.com/u/jonathan.dudley)\
**Post date:** [December 3, 2019, 1:28pm UTC](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082/31 "2019-12-03T13:28:27Z")

</div>

Hi @konrad.sopala. Thanks for moving my reply here, as I was able to find the workaround from @corruptedmonk above to get my cypress login test working.

So it’s great to have a workaround, but it would be excellent if there was a way with Auth0 SPA JS to login programmatically to our application (similar to the way proposed in the article I linked to in my previous comment), so that we would not have to login and logout every time which will slow down the test suite.

Would it be be possible for the team to add new version of the above article for Auth0 SPA JS?

Thanks.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [December 3, 2019, 1:38pm UTC](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082/32 "2019-12-03T13:38:15Z")

</div>

I guess potentially it can be possible but it all depends on team’s bandwidth. I would just suggest submitting product feedback regarding that using our feedback form:

> **[Auth0: Secure access for everyone. But not just anyone.](https://auth0.com/feedback)**
>
> Rapidly integrate authentication and authorization for web, mobile, and legacy applications so you can focus on your core business.

---

<div class="post-metadata">

**Author:** ![thisissami](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/thisissami/32/12846_2.png) [@thisissami](https://community.auth0.com/u/thisissami)\
**Post date:** [December 31, 2019, 5:35am UTC](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082/33 "2019-12-31T05:35:26Z")

</div>

Hi. Just chiming in now as I’m starting to use Cypress now.

@konrad.sopala - the solution in this thread is not an actual solution imo. It does numerous things that go against best practices that _both_ Auth0 and Cypress recommend. The point of using Auth0 is to have top-notch security… lowering the level of security (by disabling protections against malicious attacks in Auth0) in order to properly test an application should not be acceptable.

The point of this blog post was to provide a manner in which to securely test an Auth0 authenticated SPA with Cypress. This blog post seems to be outdated. I followed everything exactly as per the guide, and tried debugging this on my own with a variety of ideas for an hour or two now. I _started_ with something along the lines of what @corruptedmonk suggested until realizing that it went against both Cypress and Auth0 best practices. Then I found this guide, and was disappointed that it isn’t current.

And not only that… based off of everything everybody else is saying, even if I was able to get my `access_token`, etc. back (which I can’t - right now I’m just being redirected to `auth0.com` and getting the `html` for that page back) - this wouldn’t even work with the library that you ask everybody working with an SPA to use.

---

<div class="post-metadata">

**Author:** ![thisissami](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/thisissami/32/12846_2.png) [@thisissami](https://community.auth0.com/u/thisissami)\
**Post date:** [December 31, 2019, 5:55am UTC](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082/34 "2019-12-31T05:55:19Z")

</div>

Also to be clear: @corruptedmonk I appreciate you sharing your solution - I just expect something better of Auth0. 🙂 We shouldn’t need to compromise both app security and E2E test quality in order to authenticate test users.

---

<div class="post-metadata">

**Author:** ![corruptedmonk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/corruptedmonk/32/15605_2.png) [@corruptedmonk](https://community.auth0.com/u/corruptedmonk)\
**Post date:** [December 31, 2019, 6:31am UTC](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082/35 "2019-12-31T06:31:57Z")

</div>

@thisissami, yup it is true that my solution go against best practices of Cypress and Auth0. (That why I called it work around solution)  
But we can’t run E2E on production environment right?  
So, until now, you could setup an Test environment just for E2E test, this env will lower security of Cypress and Auth0 to run your test cases.

And in the mean time, we will wait Auth0 team to make a way for us to run E2E test with cypress.

Also to be clear that the Auth0-spa-js package is very young and it need a lot of time to improve ( also Cypress framework).

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [December 31, 2019, 10:23am UTC](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082/36 "2019-12-31T10:23:09Z")

</div>

Thanks a lot for providing all that context and feedback. I will relay it to the article author to take a look at that and implement in the near future!

---

<div class="post-metadata">

**Author:** ![dopry](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dopry/32/18899_2.png) [@dopry](https://community.auth0.com/u/dopry)\
**Post date:** [February 3, 2020, 11:43pm UTC](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082/37 "2020-02-03T23:43:36Z")

</div>

I think the author’s invocation of best practice is flawed.

“The best practice is never to visit or test third-party sites over which you have no control.”

We do have pretty extensive control over our Auth0 apps including custom domains, custom templates, and allowed URLs. Registration and Logout are key parts of the User Experience of any site. I want to know my custom templates are working, I want to know users are being redirected properly when login is triggered at different parts of a workflow or through different mechanisms.

I think it’s important that Auth0 provide the ability to perform E2E tests. It would be really nice if we could also test new universal login experience apps the same way we can classic. Lack of E2E testing support block my tenants from upgrading to New Experience.

If Auth0 can’t deliver an E2E testable platform my team will be forced to more actively look at options like ORY and KeyCloak as alternative AAA services that we can host on our own infrastructure.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [February 4, 2020, 9:12am UTC](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082/38 "2020-02-04T09:12:09Z")

</div>

Hey there!

I would ping the article author once again so we can discuss your points!

---

<div class="post-metadata">

**Author:** ![dan-auth0](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@dan-auth0](https://community.auth0.com/u/dan-auth0)\
**Post date:** [February 4, 2020, 3:44pm UTC](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082/39 "2020-02-04T15:44:37Z")

</div>

Welcome to our Auth0 Community!

I am consulting internally with our team to find out what’s the status of this and if there have been any changes on how to test the new Auth0 SPA SDK. Thank you for your time and feedback 🙏

---

<div class="post-metadata">

**Author:** ![nikolaswise](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nikolaswise/32/18929_2.png) [@nikolaswise](https://community.auth0.com/u/nikolaswise)\
**Post date:** [February 4, 2020, 9:05pm UTC](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082/41 "2020-02-04T21:05:50Z")

</div>

That would be super helpful @dan-auth0 ! I really like the autho-spa sdk, but having it break _all_ of of my tests is a big problem. Im with @dopry in thinking that if Auth0 cannot provide this, I’ll need to use another platform.

---

<div class="post-metadata">

**Author:** ![dan-auth0](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@dan-auth0](https://community.auth0.com/u/dan-auth0)\
**Post date:** [February 5, 2020, 12:28am UTC](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082/42 "2020-02-05T00:28:36Z")

</div>

The team shared that the SDK has not changed yet but one of our engineers shared this solution someone posted on GitHub:

[https://github.com/auth0/auth0-spa-js/issues/210#issuecomment-581103908](https://github.com/auth0/auth0-spa-js/issues/210#issuecomment-581103908)

What do you think, @nikolaswise, @dopry, @corruptedmonk?, @thisissami, @jonathan.dudley?

[Previous page](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082.md?page=1)

[Next page](https://community.auth0.com/t/end-to-end-testing-with-cypress-and-auth0/19082.md?page=3)
