Skip to content

Instantly share code, notes, and snippets.

@nottyo
Created May 1, 2022 03:13
Show Gist options
  • Save nottyo/14c7582bb0c8228e238a80929715a9cf to your computer and use it in GitHub Desktop.
Save nottyo/14c7582bb0c8228e238a80929715a9cf to your computer and use it in GitHub Desktop.
custom-command login
Cypress.Commands.add('lineLoginWithoutSession', (email, password) => {
const args = { email, password };
// intercept token request for checking if it's success
cy.intercept({
method: 'POST',
url: 'https://api.line.me/oauth2/v2.1/token',
}).as('createToken');
cy.visit(Cypress.config('baseUrl'));
cy.get('[data-testid="login"]').click();
cy.origin('https://access.line.me', { args }, ({ email, password }) => {
cy.get('input[type="text"]').type(email);
cy.get('input[type="password"]').type(password);
cy.get('button[type="submit"]').click();
});
// confirm that login is success!
cy.wait('@createToken').its('response.statusCode').should('eq', 200);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment