This repo shows how to write a cypress test that will programmatically login a user into Auth0.
Warning if you clone this repo it isn't going to work "as-is" you will have to add auth_config.json in the src folder and put this:
{
"domain": "my_tenant.auth0.com",
"clientId": "my_client_id"
}
Replace "my_tenant.auth0.com" and "my_client_id" with your own Auth0 domain and clientId.
Also create a cypress.env.json folder in your root directory and put this:
{
"auth_audience": "https://my_tenant.auth0.com/api/v2/",
"auth_url": "https://my_tenant.auth0.com/oauth/token",
"auth_client_id": "my_client_id",
"auth_client_secret": "my_client_secret",
"auth_username": "my_username",
"auth_password": "my_password"
}
You will have to update each one of the properties above with your own Auth0 values:
auth_password: The password of the user who cypress will be loggin in programmatically with in your tests.
Obviously the contents of both these files needs to be kept secret that's why my .gitignore has
src/auth_config.json
cypress.env.json
in it.
Also make sure to do the Auth0 Setup & Configuration steps outlined in (https://auth0.com/blog/end-to-end-testing-with-cypress-and-auth0/) in your Auth0 Application if you haven't already. Thank you Dan Lourenço!
In the project directory, you can run:
npm start
npm start
Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.
The page will reload if you make edits.
You will also see any lint errors in the console.
npm run cypress:open
npm run cypress:open
Runs cypress tests