From 4085363b198e0725cc0aa9271838ed1b50798ff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milo=C5=A1=20Jovanovi=C4=87?= Date: Fri, 25 Aug 2023 02:29:36 +0200 Subject: [PATCH] refactor: Typescript setup --- test/cypress/support/commands.d.ts | 8 ++++++++ test/cypress/support/commands.js | 2 ++ test/cypress/support/{e2e.js => e2e.ts} | 1 + test/cypress/tsconfig.json | 20 ++++++++------------ test/cypress/tsconfig.node.json | 9 +++++++++ tsconfig.json | 18 ++++++++++++++++++ vue-ts/tsconfig.json | 8 +------- 7 files changed, 47 insertions(+), 19 deletions(-) create mode 100644 test/cypress/support/commands.d.ts rename test/cypress/support/{e2e.js => e2e.ts} (98%) create mode 100644 test/cypress/tsconfig.node.json create mode 100644 tsconfig.json diff --git a/test/cypress/support/commands.d.ts b/test/cypress/support/commands.d.ts new file mode 100644 index 0000000..52eeea3 --- /dev/null +++ b/test/cypress/support/commands.d.ts @@ -0,0 +1,8 @@ +declare namespace Cypress { + interface Chainable { + loginFormCookie(url?: any, userObject?: any): Chainable + registerRequest(username?: string, password?: string): Chainable + loginRequest(username?: string, password?: string): Chainable + loginUI(username?: string, password?: string): Chainable + } +} diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js index 0a82c32..9ec2b24 100644 --- a/test/cypress/support/commands.js +++ b/test/cypress/support/commands.js @@ -23,6 +23,8 @@ // // -- This will overwrite an existing command -- // Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) +/// +// Cypress.Commands.add( "loginFormCookie", diff --git a/test/cypress/support/e2e.js b/test/cypress/support/e2e.ts similarity index 98% rename from test/cypress/support/e2e.js rename to test/cypress/support/e2e.ts index 9b26d88..70256e2 100644 --- a/test/cypress/support/e2e.js +++ b/test/cypress/support/e2e.ts @@ -21,6 +21,7 @@ import "./commands" import "cypress-plugin-xhr-toggle" +// @ts-ignore import registerCypressGrep from "@cypress/grep/src/support" registerCypressGrep() diff --git a/test/cypress/tsconfig.json b/test/cypress/tsconfig.json index 5dfa339..6ec9b5c 100644 --- a/test/cypress/tsconfig.json +++ b/test/cypress/tsconfig.json @@ -1,17 +1,13 @@ { + "extends": "../../tsconfig.json", "compilerOptions": { - "allowJs": true, "baseUrl": "../", - "esModuleInterop": true, - "lib": ["ES2022", "DOM"], - "moduleResolution": "Node", - "noEmit": true, - "paths": { - "@cy-support/*": ["cypress/support/*"] - }, - "strict": true, - "target": "ES2022", - "types": ["cypress", "vite", "node"] + "types": ["cypress", "node"] }, - "include": ["./**/*", "./vite.config.ts", "../cypress.config.ts", "../node_modules/cypress/**/*.*"] + "include": ["./**/*.*", "../node_modules/cypress/**/*.*"], + "references": [ + { + "path": "./tsconfig.node.json" + } + ] } diff --git a/test/cypress/tsconfig.node.json b/test/cypress/tsconfig.node.json new file mode 100644 index 0000000..ed62faa --- /dev/null +++ b/test/cypress/tsconfig.node.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ES2022", + "moduleResolution": "bundler" + }, + "include": ["./vite.config.ts"] +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..035a593 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "allowJs": true, + "esModuleInterop": true, + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "module": "ES2022", + "moduleResolution": "Node", + "noEmit": true, + "paths": { + "@cy-support/*": ["./test/cypress/support/*"] + }, + "resolveJsonModule": true, + "strict": true, + "target": "ES2022", + "types": ["node", "vite", "vue"] + }, + "include": ["./**/*.*"] +} diff --git a/vue-ts/tsconfig.json b/vue-ts/tsconfig.json index f82888f..f347316 100644 --- a/vue-ts/tsconfig.json +++ b/vue-ts/tsconfig.json @@ -1,21 +1,15 @@ { + "extends": "../tsconfig.json", "compilerOptions": { - "target": "ES2020", "useDefineForClassFields": true, - "module": "ESNext", - "lib": ["ES2020", "DOM", "DOM.Iterable"], "skipLibCheck": true, - /* Bundler mode */ "moduleResolution": "bundler", "allowImportingTsExtensions": true, "resolveJsonModule": true, "isolatedModules": true, - "noEmit": true, "jsx": "preserve", - /* Linting */ - "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, "noFallthroughCasesInSwitch": true