diff --git a/project/tests/controllers/InsuranceController.test.ts b/project/tests/controllers/InsuranceController.test.ts index ef04edea..2ba14de2 100644 --- a/project/tests/controllers/InsuranceController.test.ts +++ b/project/tests/controllers/InsuranceController.test.ts @@ -19,10 +19,7 @@ describe("InsuranceController", () => beforeEach(() => { - // (Re)resolve the test target. insuranceController = container.resolve("InsuranceController"); - - // Reset the insurance fixture before each test. insuranceFixture = new ProfileInsuranceFactory().adjustPackageDates().get(); }); diff --git a/project/tests/generators/BotGenerator.test.ts b/project/tests/generators/BotGenerator.test.ts index 442fc243..a94f4b33 100644 --- a/project/tests/generators/BotGenerator.test.ts +++ b/project/tests/generators/BotGenerator.test.ts @@ -1,22 +1,23 @@ /* eslint-disable @typescript-eslint/naming-convention */ import "reflect-metadata"; import { container } from "tsyringe"; -import { vi, beforeAll, afterEach, describe, expect, it } from "vitest"; +import { vi, beforeEach, afterEach, describe, expect, it } from "vitest"; import { BotGenerator } from "@spt-aki/generators/BotGenerator"; -import { BotGenerationDetails } from "@spt-aki/models/spt/bots/BotGenerationDetails"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; describe("BotGenerator", () => { let botGenerator: any; - beforeAll(() => + beforeEach(() => { botGenerator = container.resolve("BotGenerator"); }); afterEach(() => { + // Restore all mocks to their original implementations. + vi.resetAllMocks(); vi.restoreAllMocks(); }); diff --git a/project/tests/generators/BotLevelGenerator.test.ts b/project/tests/generators/BotLevelGenerator.test.ts index a7f61eee..11a96e03 100644 --- a/project/tests/generators/BotLevelGenerator.test.ts +++ b/project/tests/generators/BotLevelGenerator.test.ts @@ -1,6 +1,6 @@ import "reflect-metadata"; import { container } from "tsyringe"; -import { vi, beforeAll, afterEach, describe, expect, it } from "vitest"; +import { vi, beforeEach, afterEach, describe, expect, it } from "vitest"; import { BotLevelGenerator } from "@spt-aki/generators/BotLevelGenerator"; import { MinMax } from "@spt-aki/models/common/MinMax"; @@ -12,7 +12,7 @@ describe("BotLevelGenerator", () => let botLevelGenerator: any; let databaseServer: DatabaseServer; - beforeAll(() => + beforeEach(() => { botLevelGenerator = container.resolve("BotLevelGenerator"); databaseServer = container.resolve("DatabaseServer"); @@ -81,4 +81,4 @@ describe("BotLevelGenerator", () => expect(result).toBe(79); }); }); -}); \ No newline at end of file +}); diff --git a/project/tests/helpers/BotHelper.test.ts b/project/tests/helpers/BotHelper.test.ts index 05d89a92..f9a12537 100644 --- a/project/tests/helpers/BotHelper.test.ts +++ b/project/tests/helpers/BotHelper.test.ts @@ -1,6 +1,6 @@ import "reflect-metadata"; import { container } from "tsyringe"; -import { vi, beforeAll, afterEach, describe, expect, it } from "vitest"; +import { vi, beforeEach, afterEach, describe, expect, it } from "vitest"; import { BotHelper } from "@spt-aki/helpers/BotHelper"; @@ -8,7 +8,7 @@ describe("BotHelper", () => { let botHelper: any; - beforeAll(() => + beforeEach(() => { botHelper = container.resolve("BotHelper"); }); diff --git a/project/tests/helpers/HandbookHelper.test.ts b/project/tests/helpers/HandbookHelper.test.ts index 8007e98a..c938771a 100644 --- a/project/tests/helpers/HandbookHelper.test.ts +++ b/project/tests/helpers/HandbookHelper.test.ts @@ -1,6 +1,7 @@ import "reflect-metadata"; import { container } from "tsyringe"; -import { vi, beforeAll, afterEach, describe, expect, it } from "vitest"; +import { vi, beforeEach, afterEach, describe, expect, it } from "vitest"; + import { HandbookHelper } from "@spt-aki/helpers/HandbookHelper"; import { Money } from "@spt-aki/models/enums/Money"; @@ -8,7 +9,7 @@ describe("HandbookHelper", () => { let handbookHelper: any; - beforeAll(() => + beforeEach(() => { handbookHelper = container.resolve("HandbookHelper"); }); diff --git a/project/tests/helpers/InRaidHelper.test.ts b/project/tests/helpers/InRaidHelper.test.ts index a90c0c50..091d430d 100644 --- a/project/tests/helpers/InRaidHelper.test.ts +++ b/project/tests/helpers/InRaidHelper.test.ts @@ -1,14 +1,15 @@ -import { InRaidHelper } from "@spt-aki/helpers/InRaidHelper"; -import { DatabaseServer } from "@spt-aki/servers/DatabaseServer"; import "reflect-metadata"; import { container } from "tsyringe"; -import { vi, beforeAll, afterEach, describe, expect, it } from "vitest"; +import { vi, beforeEach, afterEach, describe, expect, it } from "vitest"; + +import { InRaidHelper } from "@spt-aki/helpers/InRaidHelper"; +import { DatabaseServer } from "@spt-aki/servers/DatabaseServer"; describe("InRaidHelper", () => { let inraidHelper: any; - beforeAll(() => + beforeEach(() => { inraidHelper = container.resolve("InRaidHelper"); }); @@ -113,4 +114,4 @@ describe("InRaidHelper", () => expect(result).toBe(0); }); }); -}); \ No newline at end of file +}); diff --git a/project/tests/helpers/ItemHelper.test.ts b/project/tests/helpers/ItemHelper.test.ts index 1fa7b023..2fba68d6 100644 --- a/project/tests/helpers/ItemHelper.test.ts +++ b/project/tests/helpers/ItemHelper.test.ts @@ -1,6 +1,6 @@ import "reflect-metadata"; import { container } from "tsyringe"; -import { vi, beforeAll, afterEach, describe, expect, it } from "vitest"; +import { vi, beforeEach, afterEach, describe, expect, it } from "vitest"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { Item, Repairable } from "@spt-aki/models/eft/common/tables/IItem"; @@ -11,7 +11,7 @@ describe("ItemHelper", () => { let itemHelper: ItemHelper; - beforeAll(() => + beforeEach(() => { itemHelper = container.resolve("ItemHelper"); }); diff --git a/project/tests/services/ItemBaseClassService.test.ts b/project/tests/services/ItemBaseClassService.test.ts index 716d6d53..d94f9503 100644 --- a/project/tests/services/ItemBaseClassService.test.ts +++ b/project/tests/services/ItemBaseClassService.test.ts @@ -1,14 +1,14 @@ /* eslint-disable @typescript-eslint/naming-convention */ import "reflect-metadata"; import { container } from "tsyringe"; -import { vi, beforeAll, afterEach, describe, expect, it } from "vitest"; +import { vi, beforeEach, afterEach, describe, expect, it } from "vitest"; import { ItemBaseClassService } from "@spt-aki/services/ItemBaseClassService"; describe("ItemBaseClassService", () => { let itemBaseClassService: any; - beforeAll(() => + beforeEach(() => { itemBaseClassService = container.resolve("ItemBaseClassService"); }); @@ -73,9 +73,9 @@ describe("ItemBaseClassService", () => { // Set cache to false itemBaseClassService.cacheGenerated = false; - + const hydrateItemBaseClassCacheSpy = vi.spyOn(itemBaseClassService, "hydrateItemBaseClassCache"); - + // Remove item from base cache const salewaTpl = "544fb45d4bdc2dee738b4568"; delete itemBaseClassService.itemBaseClassesCache[salewaTpl]; diff --git a/project/tests/services/PaymentService.test.ts b/project/tests/services/PaymentService.test.ts index 6884f663..8a5f8dd5 100644 --- a/project/tests/services/PaymentService.test.ts +++ b/project/tests/services/PaymentService.test.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/naming-convention */ import "reflect-metadata"; import { container } from "tsyringe"; -import { vi, beforeAll, afterEach, describe, expect, it } from "vitest"; +import { vi, beforeEach, afterEach, describe, expect, it } from "vitest"; import { PaymentService } from "@spt-aki/services/PaymentService"; @@ -16,7 +16,7 @@ describe("PaymentService", () => { let paymentService: any; // Using "any" to access private/protected methods without type errors. - beforeAll(() => + beforeEach(() => { paymentService = container.resolve("PaymentService"); }); diff --git a/project/tests/services/PlayerService.test.ts b/project/tests/services/PlayerService.test.ts index 66e66d5d..1fb36d05 100644 --- a/project/tests/services/PlayerService.test.ts +++ b/project/tests/services/PlayerService.test.ts @@ -1,7 +1,8 @@ /* eslint-disable @typescript-eslint/naming-convention */ import "reflect-metadata"; import { container } from "tsyringe"; -import { vi, beforeAll, afterEach, describe, expect, it } from "vitest"; +import { vi, beforeEach, afterEach, describe, expect, it } from "vitest"; + import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { PlayerService } from "@spt-aki/services/PlayerService"; @@ -9,7 +10,7 @@ describe("PlayerService", () => { let playerService: PlayerService; - beforeAll(() => + beforeEach(() => { playerService = container.resolve("PlayerService"); });