Test Account Portal flows
Testing navigation flows with Cypress can be challenging, especially when redirects to external URLs are involved. This guide demonstrates how to use Cypress to test the Account Portal flow, including the redirect to the Account Portal and back to your app.
Get your Account Portal domain
To get your Account Portal domain, navigate to the Account Portal page in the Clerk Dashboard. The domain format should resemble: https://verb-noun-00.accounts.dev
The test format
Cypress's cy.origin()
function lets you visit multiple domains of different origins in the same test. For more information, see the Cypress documentation.
By passing your Account Portal domain to cy.origin()
, your test can navigate to the Account Portal domain and then return to your app.
Structure tests that include Account Portal redirects as follows:
Example
The following example creates a test that:
- visits a protected page, which redirects to the Account Portal when not signed in
- completes the form to sign in
- redirects back to the protected page
Feedback
Last updated on