diff --git a/cypress/e2e/invite.cy.js b/cypress/e2e/invite.cy.js index 5786ccc7..0923fc6d 100644 --- a/cypress/e2e/invite.cy.js +++ b/cypress/e2e/invite.cy.js @@ -1,6 +1,8 @@ describe("Invite User into league and change some league Settings and run through a matchday.", () => { before(() => { - cy.exec("export APP_ENV=test; node cypress/e2e/invite1.js"); + cy.exec( + "export APP_ENV=test; ts-node --project=./tsconfig2.json cypress/e2e/invite1.ts", + ); }); // Used to signup change username and password and login again it("invite", () => { @@ -227,7 +229,9 @@ describe("Invite User into league and change some league Settings and run throug .click(); cy.contains("Buying"); // Starts the matchday - cy.exec("export APP_ENV=test; node cypress/e2e/invite2.js").then(() => { + cy.exec( + "export APP_ENV=test; ts-node --project=./tsconfig2.json cypress/e2e/invite2.ts", + ).then(() => { cy.contains("Transfers").click(); }); cy.contains("Transfer Market closed"); @@ -283,7 +287,9 @@ describe("Invite User into league and change some league Settings and run throug ); cy.contains("Erling Haaland").parent().parent().parent().contains("0"); // Sims matchday until all players have played - cy.exec("export APP_ENV=test; node cypress/e2e/invite3.js"); + cy.exec( + "export APP_ENV=test; ts-node --project=./tsconfig2.json cypress/e2e/invite3.ts", + ); // Checks that the user points are correct cy.contains("Standings").click(); cy.get(".MuiTableBody-root > :nth-child(1) > :nth-child(2)").contains("44"); @@ -327,7 +333,9 @@ describe("Invite User into league and change some league Settings and run throug .contains("Player has already played"); matchdays.push({ invite1: user1Money, invite2: user2Money }); // Starts the transfer period and sells Muller - cy.exec("export APP_ENV=test; node cypress/e2e/invite4.js"); + cy.exec( + "export APP_ENV=test; ts-node --project=./tsconfig2.json cypress/e2e/invite4.ts", + ); cy.intercept("/api/player/Bundesliga/ef5112a9f971a1e40966").as( "loadRobert", ); @@ -444,7 +452,9 @@ describe("Invite User into league and change some league Settings and run throug cy.contains("19.7 M"); matchdays.push({ invite1: user1Money, invite2: user2Money }); // Simulates an empty matchday - cy.exec("export APP_ENV=test; node cypress/e2e/invite5.js"); + cy.exec( + "export APP_ENV=test; ts-node --project=./tsconfig2.json cypress/e2e/invite5.ts", + ); // Adds a third user that joins late cy.clearCookies(); cy.get("#logout").click(); @@ -478,7 +488,9 @@ describe("Invite User into league and change some league Settings and run throug cy.get("#confirmation").type("New Sample League"); cy.contains("Save admin settings").click(); // Simulates an empty matchday - cy.exec("export APP_ENV=test; node cypress/e2e/invite5.js"); + cy.exec( + "export APP_ENV=test; ts-node --project=./tsconfig2.json cypress/e2e/invite5.ts", + ); // Makes sure that the matchday does not exist cy.go("back").then(() => { cy.get(".MuiPagination-ul > :nth-child(4) > .MuiButtonBase-root") diff --git a/cypress/e2e/invite1.js b/cypress/e2e/invite1.ts similarity index 69% rename from cypress/e2e/invite1.js rename to cypress/e2e/invite1.ts index b1f7bc75..e6b76499 100644 --- a/cypress/e2e/invite1.js +++ b/cypress/e2e/invite1.ts @@ -1,9 +1,10 @@ +import connect from "#database"; +import { updateData } from "#scripts/update"; + run(); // Used to reset the users and invites for the user test async function run() { - const database = require("../../Modules/database"); - const updateData = require("../../scripts/update.js").updateData; - const connection = await database.default(); + const connection = await connect(); await connection.query("DELETE FROM users WHERE username like 'Invite%'"); await connection.query("DELETE FROM invite WHERE inviteID='invite1'"); await connection.query("DELETE FROM data WHERE value1='locked'"); diff --git a/cypress/e2e/invite2.js b/cypress/e2e/invite2.ts similarity index 60% rename from cypress/e2e/invite2.js rename to cypress/e2e/invite2.ts index fef71102..da5fda52 100644 --- a/cypress/e2e/invite2.js +++ b/cypress/e2e/invite2.ts @@ -1,6 +1,7 @@ +import { updateData } from "#scripts/update"; + run(); // Starts the matchday async function run() { - const updateData = require("../../scripts/update.js").updateData; await updateData("", "./sample/data2.json"); } diff --git a/cypress/e2e/invite3.js b/cypress/e2e/invite3.ts similarity index 60% rename from cypress/e2e/invite3.js rename to cypress/e2e/invite3.ts index 81c405c6..6f2ffc92 100644 --- a/cypress/e2e/invite3.js +++ b/cypress/e2e/invite3.ts @@ -1,6 +1,7 @@ +import { updateData } from "#scripts/update"; + run(); // Simulates all the games async function run() { - const updateData = require("../../scripts/update.js").updateData; await updateData("", "./sample/data3.json"); } diff --git a/cypress/e2e/invite4.js b/cypress/e2e/invite4.ts similarity index 75% rename from cypress/e2e/invite4.js rename to cypress/e2e/invite4.ts index 53b55489..f38b7d02 100644 --- a/cypress/e2e/invite4.js +++ b/cypress/e2e/invite4.ts @@ -1,7 +1,8 @@ +import { updateData } from "#scripts/update"; + run(); // Checks if the data after the games have changed gets updated and ends the matchday async function run() { - const updateData = require("../../scripts/update.js").updateData; await updateData("", "./sample/data4.json"); await updateData("", "./sample/data5.json"); } diff --git a/cypress/e2e/invite5.js b/cypress/e2e/invite5.ts similarity index 68% rename from cypress/e2e/invite5.js rename to cypress/e2e/invite5.ts index e795ce74..39382ba5 100644 --- a/cypress/e2e/invite5.js +++ b/cypress/e2e/invite5.ts @@ -1,7 +1,8 @@ +import { updateData } from "#scripts/update"; + run(); // Simulates a matchday async function run() { - const updateData = require("../../scripts/update.js").updateData; await updateData("", "./sample/data6.json"); await updateData("", "./sample/data5.json"); } diff --git a/cypress/e2e/user.cy.js b/cypress/e2e/user.cy.js index 85c2c8c3..8d696542 100644 --- a/cypress/e2e/user.cy.js +++ b/cypress/e2e/user.cy.js @@ -1,6 +1,8 @@ describe("User", () => { before(() => { - cy.exec("export APP_ENV=test; node cypress/e2e/user.js"); + cy.exec( + "export APP_ENV=test; ts-node --project=./tsconfig2.json cypress/e2e/user.ts", + ); }); // Used to signup change username and password and login again it("signup", () => { diff --git a/cypress/e2e/user.js b/cypress/e2e/user.ts similarity index 68% rename from cypress/e2e/user.js rename to cypress/e2e/user.ts index 89ee43ea..b3912665 100644 --- a/cypress/e2e/user.js +++ b/cypress/e2e/user.ts @@ -1,8 +1,9 @@ +import connect from "#database"; + run(); // Used to reset the users for the user test async function run() { - const database = require("../../Modules/database"); - const connection = await database.default(); + const connection = await connect(); connection.query( "DELETE FROM users WHERE username='Sample User' or username='New Sample Username'", ); diff --git a/tsconfig3.json b/tsconfig3.json deleted file mode 100644 index 3d75b78c..00000000 --- a/tsconfig3.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "compilerOptions": { - "paths": { - "#/*": ["./*"], - "#components/*": ["./components/*"], - "#Modules/*": ["./Modules/*"], - "#type/*": ["./types/*"], - "#scripts/*": ["./scripts/*.js"], - "#database": ["./Modules/database"] - }, - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "allowJs": true, - "skipLibCheck": true, - "strict": true, - "forceConsistentCasingInFileNames": true, - "incremental": true, - "esModuleInterop": true, - "target": "esnext", - "module": "commonjs", - "moduleResolution": "node", - "resolveJsonModule": true, - "isolatedModules": true - }, - "include": ["./scripts/entrypoint.ts"] -}