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.
Important
Check out the demo repo that demonstrates testing a Clerk-powered application using Testing Tokens. To run the tests, you'll need dev instance Clerk API keys, a test user with username and password, and have username and password authentication enabled in the Clerk Dashboard.
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
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: