I need to write a cypress test for my app which uses federated login (Google). I am getting CORS error even after I have disabled chromeWebSecurity. Does anyone have any sample code for that?
describe('log in with google', ()=>{
it('should work', ()=>{
cy.visit('http://localhost:3000/')
cy.contains('Log in with Google').click()
cy.get("input#identifierId").type('[email protected]{enter}');
cy.wait(5000);
cy.get("input[@type=password]").type('<Pwd>{enter}');
})
})
Thanks!
There is a library called cypress-social-login which does just that.
It's recommended by the cypress team and can be found on the cypress plugin page.
https://github.com/lirantal/cypress-social-logins
This Cypress library makes it possible to perform third-party logins (think oauth) for services such as GitHub, Google or Facebook.
It does so by delegating the login process to a puppeteer flow that performs the login and returns the cookies for the application under test so they can be set by the calling Cypress flow for the duration of the test.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With