lirantal / cypress-social-logins

Cypress authentication flows using social network providers
Apache License 2.0
247 stars 78 forks source link

No overload matches this call error in then block (code attached) #124

Closed tae100k closed 1 month ago

tae100k commented 2 years ago

Hello, thanks for making this plugins. It really helps me a lot to test social login. Just one thing is that I have type error here. I looked up a lot, and still haven't figured out how to do it.

Error message

No overload matches this call. The last overload gave the following error. Argument of type '({ cookies }: { cookies: cookieType[]; }) => void' is not assignable to parameter of type '(this: ObjectLike, currentSubject: unknown) => void'. Types of parameters '__0' and 'currentSubject' are incompatible. Type 'unknown' is not assignable to type '{ cookies: cookieType[]; }'.

my codes

[auth.cy.ts]

import 'cypress-localstorage-commands';

interface cookieType {
  domain: string;
  expires: number;
  httpOnly: boolean;
  name: string;
  path: string;
  secure: boolean;
  session: boolean;
  size: number;
  value: string;
}

describe(`Google`, () => {
  it('should login successfully with google email', () => {
    const { googleEmail, googlePassword } = Cypress.env('testUser');
    const socialLoginOptions = {
      username: googleEmail,
      password: googlePassword,

      loginUrl: 'https://voicelab-local.lovo.ai/signin',
      preLoginSelector: '[data-testid="main-image-container"]',
      loginSelector: '[data-testid="google-login-button"]',
      postLoginSelector: '[data-testid="workspace-container"]',
      headless: false,

      popupDelay: 4000,
      cookieDelay: 3000,
      loginSelectorDelay: 2000,

      isPopup: true,
    };
    cy.clearLocalStorageSnapshot();

    cy.task(`GoogleSocialLogin`, socialLoginOptions).then(({ cookies }: { cookies: cookieType[] }) => {
      cookies.map((cookie: cookieType) => {
        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: cookie.name,
        });
      });

      cy.visit('/my-workspace/project');
    });
  });
});

import * as dotenv from 'dotenv'; import path from 'path';

const { GoogleSocialLogin } = require('cypress-social-logins').plugins;

dotenv.config({ path: path.resolve(process.cwd(), '.vercel', '.env.development.local'), });

export default defineConfig({ viewportWidth: 1280, viewportHeight: 800, env: { /**