Skip to content

Instantly share code, notes, and snippets.

@sir-dunxalot
Created May 26, 2020 03:11
Show Gist options
  • Save sir-dunxalot/5c3b1b1c20d56629ec1b4d9d81f5268a to your computer and use it in GitHub Desktop.
Save sir-dunxalot/5c3b1b1c20d56629ec1b4d9d81f5268a to your computer and use it in GitHub Desktop.
cypress-nextjs-auth0__helper--login-with-multiple-users
Cypress.Commands.add('login', (credentials?: Credentials = {}) => {
const { username, password } = credentials;
const credentials = {
username: username || Cypress.env('auth0Username'),
password: password || Cypress.env('auth0Password'),
};
/* ... */
});
context('Logging in', () => {
it('should successfully log in', () => {
cy.login({
username: Cypress.env('auth0UsernameAlt'),
password: Cypress.env('auth0PasswordAlt'),
}).then(() => {
cy.visit('/');
cy.request('/api/me').then(({ body: user }) => {
expect(user).to.exist;
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment