-
Notifications
You must be signed in to change notification settings - Fork 389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose the CookieHelper for testing with Cypress #335
Comments
We have encountered the same issue. Would love first class support for this or a reasonable workaround. |
Hi @shicholas - thanks for raising this We're looking into adding better support for end to end testing, but we need to be careful that features we add can't be abused in production. In the meantime - I've created a PR to update https://github.com/sir-dunxalot/cypress-nextjs-auth0 - which should give you an idea for how to implement this yourself, regardless of if it get's merged or not. Also, have a look at our sample app for options on stubbing the client side code. |
Closing this - but we do have something in our backlog to explore this further |
Hi @adamjmcgrath - thanks for the provided example and PR, but is there any way that I could use my The reason for this is that I have some additional logic included in |
Hi @HannuPousi - since your cypress tests run in the browser I'm not sure how you'd do this. You'd have to find some creative solution to this. Perhaps something like exporting your |
Describe the problem you'd like to have solved
For codebases that use
auth0/react
andcypress
, it has been previously recommended by both companies to use a POST endpoint to get an access token programmatically then set the localStorage with the output of the body from the POST endpoint.We'd like to continue testing in a similar way here, but now need to know how to encrypt a cookie, which we can then set.
Please refer to https://github.com/NeonLaw/codebase/blob/a2009879cf2bfaed5241f5a2a9789fb36b6c5bbf/web/cypress/support/commands.js#L29-L40, which contains code that was working with
@auth0/react
but cannot work with this library as cookies are encrypted.I tried out https://github.com/sir-dunxalot/cypress-nextjs-auth0, which is great, but uses a different encryption mechanism, (
@hapi/iron
instead of thejose
library) and therefore cannot work out-of-the-box with this library.Describe the ideal solution
It would be nice to be able to write a custom command like this:
Alternatives and current work-arounds
Right now, I'd have to monkey/patch or copy too much code into my Cypress tests or update the other library above to get this to work. It'd be nice if there was a first-class way to programmatically encrypt cookies for testing. This could work with more libraries than just Cypress.
Additional information, if any
I'll try my best to clarify anything that's unclear here. Thanks!
The text was updated successfully, but these errors were encountered: