Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Anyone has an example in cypress that uses Google login

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!

like image 298
Gohawks Avatar asked Nov 26 '18 18:11

Gohawks


1 Answers

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.

like image 187
Gal Margalit Avatar answered Oct 11 '22 20:10

Gal Margalit