From 666cef4e59668b7917de0e544c4eb6b6c691b721 Mon Sep 17 00:00:00 2001 From: "krivokhizhin.a" Date: Thu, 28 Sep 2023 19:56:01 +0300 Subject: [PATCH] use generic types for cy.then and cy.get aliases --- cypress/e2e/smoke.cy.ts | 2 +- cypress/support/commands.ts | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cypress/e2e/smoke.cy.ts b/cypress/e2e/smoke.cy.ts index f62a86ee..4b0d9e5a 100644 --- a/cypress/e2e/smoke.cy.ts +++ b/cypress/e2e/smoke.cy.ts @@ -11,7 +11,7 @@ describe("smoke tests", () => { password: faker.internet.password(), }; - cy.then(() => ({ email: loginForm.email })).as("user"); + cy.then<{ email: string }>(() => ({ email: loginForm.email })).as("user"); cy.visitAndCheck("/"); diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 0865e4e1..b41ec0b3 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -47,7 +47,7 @@ function login({ }: { email?: string; } = {}) { - cy.then(() => ({ email })).as("user"); + cy.then<{ email: string }>(() => ({ email })).as("user"); cy.exec( `npx ts-node --require tsconfig-paths/register ./cypress/support/create-user.ts "${email}"`, ).then(({ stdout }) => { @@ -56,15 +56,14 @@ function login({ .trim(); cy.setCookie("__session", cookieValue); }); - return cy.get("@user"); + return cy.get<{ email?: string }>("@user"); } function cleanupUser({ email }: { email?: string } = {}) { if (email) { deleteUserByEmail(email); } else { - cy.get("@user").then((user) => { - const email = (user as { email?: string }).email; + cy.get<{ email?: string }>("@user").then(({ email }) => { if (email) { deleteUserByEmail(email); }