From 6b7be9f87b26e45d3860af974eac9de3bf63b4a8 Mon Sep 17 00:00:00 2001 From: JP Sugarbroad Date: Sat, 16 Apr 2022 17:29:21 -0700 Subject: [PATCH] fix typing conflict between jest and cypress Cypress and Jest both define "expect", but they come from different libraries (Cypress uses Chai, Jest uses its own thing). So we can't include both of them in the tsconfig.json. Conveniently, however, we don't need any of the test code to be part of the main project, so it suffices to give cypress its own tsconfig.json file. That being done, adding "jest" to the global types lets us remove all those imports. --- package.json | 1 + test/cypress/tsconfig.json | 11 +++++++++++ test/jest/Netscript/DynamicRamCalculation.test.js | 2 -- test/jest/Netscript/StaticRamCalculation.test.js | 2 -- .../Netscript/StaticRamParsingCalculation.test.js | 3 --- test/jest/Script/Script.test.ts | 3 --- test/jest/StockMarket.test.ts | 3 --- test/jest/StringHelperFunctions.test.ts | 2 -- test/jest/Terminal/Directory.test.js | 2 -- ...determineAllPossibilitiesForTabCompletion.test.ts | 2 -- test/jest/ui/nFormat.test.js | 1 - tsconfig.json | 12 +++++++----- 12 files changed, 19 insertions(+), 25 deletions(-) create mode 100644 test/cypress/tsconfig.json diff --git a/package.json b/package.json index 11cac076b..0cfff5783 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,7 @@ "@types/bcryptjs": "^2.4.2", "@types/escodegen": "^0.0.7", "@types/file-saver": "^2.0.3", + "@types/jest": "^27.4.1", "@types/jquery": "^3.5.14", "@types/lodash": "^4.14.168", "@types/numeral": "^2.0.2", diff --git a/test/cypress/tsconfig.json b/test/cypress/tsconfig.json new file mode 100644 index 000000000..add5be47b --- /dev/null +++ b/test/cypress/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "esModuleInterop": true, + "isolatedModules": true, + "module": "commonjs", + "noEmit": true, + "strict": true, + "target": "es6", + "types": ["cypress", "@testing-library/cypress"] + } +} diff --git a/test/jest/Netscript/DynamicRamCalculation.test.js b/test/jest/Netscript/DynamicRamCalculation.test.js index b08e09ba8..be823ed70 100644 --- a/test/jest/Netscript/DynamicRamCalculation.test.js +++ b/test/jest/Netscript/DynamicRamCalculation.test.js @@ -1,5 +1,3 @@ -import { jest, describe, expect } from "@jest/globals"; - import { Player } from "../../../src/Player"; import { NetscriptFunctions } from "../../../src/NetscriptFunctions"; import { getRamCost, RamCostConstants } from "../../../src/Netscript/RamCostGenerator"; diff --git a/test/jest/Netscript/StaticRamCalculation.test.js b/test/jest/Netscript/StaticRamCalculation.test.js index 3ac978d0b..9d5a11b10 100644 --- a/test/jest/Netscript/StaticRamCalculation.test.js +++ b/test/jest/Netscript/StaticRamCalculation.test.js @@ -1,5 +1,3 @@ -import { jest, describe, expect } from "@jest/globals"; - import { Player } from "../../../src/Player"; import { getRamCost, RamCostConstants } from "../../../src/Netscript/RamCostGenerator"; import { calculateRamUsage } from "../../../src/Script/RamCalculations"; diff --git a/test/jest/Netscript/StaticRamParsingCalculation.test.js b/test/jest/Netscript/StaticRamParsingCalculation.test.js index eba80b16c..86a2fa14a 100644 --- a/test/jest/Netscript/StaticRamParsingCalculation.test.js +++ b/test/jest/Netscript/StaticRamParsingCalculation.test.js @@ -1,6 +1,3 @@ -// eslint-disable-next-line @typescript-eslint/no-unused-vars -import { describe, expect, jest } from "@jest/globals"; - // Player is needed for calculating costs like Singularity functions, that depend on acquired source files import { Player } from "../../../src/Player"; diff --git a/test/jest/Script/Script.test.ts b/test/jest/Script/Script.test.ts index c3a299088..c7a435dcb 100644 --- a/test/jest/Script/Script.test.ts +++ b/test/jest/Script/Script.test.ts @@ -1,6 +1,3 @@ -// eslint-disable-next-line @typescript-eslint/no-unused-vars -import { jest, describe, expect, test } from "@jest/globals"; - import { Script } from "../../../src/Script/Script"; import { Player } from "../../../src/Player"; diff --git a/test/jest/StockMarket.test.ts b/test/jest/StockMarket.test.ts index 37cbe0651..a989c68c5 100644 --- a/test/jest/StockMarket.test.ts +++ b/test/jest/StockMarket.test.ts @@ -1,6 +1,3 @@ -// eslint-disable-next-line @typescript-eslint/no-unused-vars -import { jest, describe, expect, test } from "@jest/globals"; - import { CONSTANTS } from "../../src/Constants"; import { Player } from "../../src/Player"; import { IMap } from "../../src/types"; diff --git a/test/jest/StringHelperFunctions.test.ts b/test/jest/StringHelperFunctions.test.ts index b81659f99..e31e5664e 100644 --- a/test/jest/StringHelperFunctions.test.ts +++ b/test/jest/StringHelperFunctions.test.ts @@ -1,5 +1,3 @@ -// eslint-disable-next-line @typescript-eslint/no-unused-vars -import { jest, describe, expect, test } from "@jest/globals"; import { convertTimeMsToTimeElapsedString } from "../../src/utils/StringHelperFunctions"; describe("StringHelperFunctions Tests", function () { diff --git a/test/jest/Terminal/Directory.test.js b/test/jest/Terminal/Directory.test.js index 337a96ca4..04f429a22 100644 --- a/test/jest/Terminal/Directory.test.js +++ b/test/jest/Terminal/Directory.test.js @@ -1,5 +1,3 @@ -// eslint-disable-next-line @typescript-eslint/no-unused-vars -import { jest, describe, expect, test } from "@jest/globals"; import * as dirHelpers from "../../../src/Terminal/DirectoryHelpers"; describe("Terminal Directory Tests", function () { diff --git a/test/jest/Terminal/determineAllPossibilitiesForTabCompletion.test.ts b/test/jest/Terminal/determineAllPossibilitiesForTabCompletion.test.ts index 9c3365ee1..adbcc4c63 100644 --- a/test/jest/Terminal/determineAllPossibilitiesForTabCompletion.test.ts +++ b/test/jest/Terminal/determineAllPossibilitiesForTabCompletion.test.ts @@ -1,7 +1,5 @@ import { CityName } from "./../../../src/Locations/data/CityNames"; /* eslint-disable no-await-in-loop */ -// eslint-disable-next-line @typescript-eslint/no-unused-vars -import { jest, describe, expect, test } from "@jest/globals"; import { Player } from "../../../src/Player"; import { determineAllPossibilitiesForTabCompletion } from "../../../src/Terminal/determineAllPossibilitiesForTabCompletion"; diff --git a/test/jest/ui/nFormat.test.js b/test/jest/ui/nFormat.test.js index f3fc6b156..863cea889 100644 --- a/test/jest/ui/nFormat.test.js +++ b/test/jest/ui/nFormat.test.js @@ -1,4 +1,3 @@ -import { describe, expect, test } from "@jest/globals"; import { numeralWrapper } from "../../../src/ui/numeralFormat"; let decimalFormat = "0.[000000]"; diff --git a/tsconfig.json b/tsconfig.json index 3cfda7488..8af40ee3a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,13 +4,15 @@ "esModuleInterop": true, "isolatedModules": true, "jsx": "react", - "lib": ["es2016", "dom", "es2017.object", "es2019"], "module": "commonjs", - "target": "es6", + "noEmit": true, + "resolveJsonModule": true, + "skipLibCheck": true, "sourceMap": true, "strict": true, - "resolveJsonModule": true, - "types": ["cypress", "@testing-library/cypress", "node"] + "target": "es2019", + "types": ["jest", "node"] }, - "exclude": ["node_modules"] + "include": ["src/**/*", "test/**/*"], + "exclude": ["test/cypress/**/*"] }