Actually working Auth-0 SPA SDK + Cypress test

TL;DR: Great reference for cypress testing of components affected by the Auth-0 SPA SDK state: GitHub - adamjmcgrath/cypress-spa-example

Hi all,

After weeks of not getting our cypress tests working, we finally found this repo by Adam Grath: GitHub - adamjmcgrath/cypress-spa-example

It gives a very simple and clear example on how to implement the JS SPA SDK login and logout and it works straight out of the box with little configuration to fit your own tenant details. While we’re not related to the contributor we really enjoyed a simple solution compared to the insane amount of work-arounds presented out there and in the comment section of the official Auth-0 blog post (End-to-End Testing with Cypress and Auth0) which doesn’t address how to test secured pages / content.

The only back-draw is that one has to use localstorage for the Auth-0 token. However, functionality should be just as when using memory.

1 Like

Hi @rico,

Welcome to the Community!

Thanks for providing some insight on this. I have seen some requests recently for an update to the blog, and I submitted a ticket to our team a few days ago, should be hearing back about the status of that post at any time.

I’m sure @adam.mcgrath will appreciate the praise too!

Hey @rico thanks for the pointer. I’m through my own drama to get this to work, to no avail.

Just in case, could you specify what this is? I do get a valid response back from the /oauth/token end point, so my guess is that I just need to write the local storage content that the SPA SDK expects (mine uses “default”, for example), but I haven’t been able to get it to work.

Thanks,

Juan