cypress-social-logins icon indicating copy to clipboard operation
cypress-social-logins copied to clipboard

Tests are running successfully locally, but consistently receiving a timeout when running in CI

Open ryanwoconnor opened this issue 2 years ago • 1 comments

I have the following test which works fine locally. However when run from CI I consistently am getting a timeout when trying to get the postLoginSelector.

Any ideas on why this might be?

  │ Cypress:        10.7.0                                                                         │
  │ Browser:        Electron 102 (headless)                                                        │
  │ Node Version:   v16.13.0 (/Users/ryanoconnor/.nvm/versions/node/v16.13.0/bin/node)             │
  │ Specs:          1 found (login.cy.ts)                                                          │
  │ Searched:       cypress/e2e/**/*.cy.{js,jsx,ts,tsx}         
describe("Login page", () => {
  before(() => {
    cy.log(`Visiting http://localhost:3000`);
    cy.visit("http://localhost:3000");
  });
  it("Login with Google", () => {
    const username = Cypress.env("GOOGLE_USER");
    const password = Cypress.env("GOOGLE_PW");
    const loginUrl = Cypress.env("SITE_NAME");
    const cookieName = Cypress.env("COOKIE_NAME");
    const socialLoginOptions = {
      username,
      password,
      loginUrl,
      headless: true,
      logs: true,
      isPopup: true,
      loginSelector: "button.GoogleButton",
      postLoginSelector: ".cleanersharelogo",
    };

    return cy
      .task("GoogleSocialLogin", socialLoginOptions)
      .then(({ cookies }) => {
        cy.clearCookies();
        const cookie = cookies
          .filter((cookie) => cookie.name === cookieName)
          .pop();
        if (cookie) {
          cy.setCookie(cookie.name, cookie.value, {
            domain: cookie.domain,
            expiry: cookie.expires,
            httpOnly: cookie.httpOnly,
            path: cookie.path,
            secure: cookie.secure,
          });

          Cypress.Cookies.defaults({
            preserve: cookieName,
          });

          // remove the two lines below if you need to stay logged in
          // for your remaining tests

          cy.visit("http://localhost:3000/");
          cy.wait(1000);

          cy.visit("http://localhost:3000/api/auth/signout");
          cy.get("form").submit();
        }
      });
  });
});

export {};

ryanwoconnor avatar Sep 09 '22 03:09 ryanwoconnor

Potentially due to this issue mentioned in the README?

This plugin doesn't work well in a CI environment, due to the anti-fraud detection mechanisms employed by the likes of Google, GitHub etc.

ghost avatar Oct 30 '22 20:10 ghost