From 5ce5ebb3b6eaa5464017ee3fe9aafbbab531ef0d Mon Sep 17 00:00:00 2001 From: Dominik Stahl Date: Mon, 12 May 2025 22:59:55 +0200 Subject: [PATCH] test: helper functions --- cypress/support/commands.ts | 25 +++++++++++++++++++++++++ cypress/support/component.ts | 2 ++ tsconfig.json | 3 ++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 95857ae..59717f5 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -35,3 +35,28 @@ // } // } // } + +Cypress.Commands.add('getBySel', (selector, ...args) => { + return cy.get(`[data-cy=${selector}]`, ...args); +}); + +Cypress.Commands.add('getBySelLike', (selector, ...args) => { + return cy.get(`[data-cy*=${selector}]`, ...args); +}); + +declare global { + namespace Cypress { + interface Chainable { + getBySel( + selector: string, + ...args: any[] + ): Chainable>; + getBySelLike( + selector: string, + ...args: any[] + ): Chainable>; + } + } +} + +export {}; diff --git a/cypress/support/component.ts b/cypress/support/component.ts index 23fbccc..b1f1c92 100644 --- a/cypress/support/component.ts +++ b/cypress/support/component.ts @@ -13,6 +13,8 @@ // https://on.cypress.io/configuration // *********************************************************** +import '@/app/globals.css'; + // Import commands.js using ES2015 syntax: import './commands'; diff --git a/tsconfig.json b/tsconfig.json index c133409..6bd88b8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,7 +20,8 @@ ], "paths": { "@/*": ["./src/*"] - } + }, + "types": ["node", "cypress"] }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], "exclude": ["node_modules"]