cypress-social-logins
cypress-social-logins copied to clipboard
No overload matches this call error in then block (code attached)
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');
});
});
});
- just in case, if I need to do typing in cypress.config.ts [cypress.config.ts]
import { defineConfig } from 'cypress';
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: {
/**
* Enter you account to test in local environment.
* In CI environment, It will use the account from env variables.
* Delete yout account before push
*/
testUser: {
email: '' || process.env.TEST_USER_ID,
password: '' || process.env.TEST_USER_PW,
},
apiUrl: process.env.NEXT_PUBLIC_API_SERVER_URL,
},
component: {
devServer: {
framework: 'next',
bundler: 'webpack',
},
},
watchForFileChanges: false,
clientCertificates: [
{
url: 'https://voicelab-local.lovo.ai',
ca: [],
certs: [
{
cert: 'nginx/voicelab-local.lovo.ai.pem',
key: 'nginx/voicelab-local.lovo.ai-key.pem',
},
],
},
],
e2e: {
baseUrl: 'https://voicelab-local.lovo.ai',
defaultCommandTimeout: 10000,
setupNodeEvents(on) {
on('task', {
GoogleSocialLogin,
});
},
},
});