Created
May 1, 2022 03:13
-
-
Save nottyo/14c7582bb0c8228e238a80929715a9cf to your computer and use it in GitHub Desktop.
custom-command login
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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