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 these things their own tsconfig.json files.

That being done, adding "jest" to the global types lets us remove all
those imports.
This commit is contained in:
JP Sugarbroad
2022-05-10 20:04:19 -07:00
parent ce888b757a
commit 01529a8347
13 changed files with 24 additions and 25 deletions

View File

@@ -0,0 +1,9 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"checkJs": true,
"types": ["cypress", "@testing-library/cypress"]
},
"include": ["**/*"],
"exclude": []
}

View File

@@ -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";

View File

@@ -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";

View File

@@ -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";

View File

@@ -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";

View File

@@ -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";

View File

@@ -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 () {

View File

@@ -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 () {

View File

@@ -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";

View File

@@ -1,4 +1,3 @@
import { describe, expect, test } from "@jest/globals";
import { numeralWrapper } from "../../../src/ui/numeralFormat";
let decimalFormat = "0.[000000]";

9
test/tsconfig.json Normal file
View File

@@ -0,0 +1,9 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"allowJs": true,
"types": ["jest"]
},
"include": ["**/*", "../src/**/*.d.ts"],
"exclude": ["cypress/**/*"]
}