diff --git a/project/tests/CustomEnvironment.ts b/project/tests/CustomEnvironment.ts index 4580b43e..f700cc61 100644 --- a/project/tests/CustomEnvironment.ts +++ b/project/tests/CustomEnvironment.ts @@ -1,5 +1,5 @@ import "reflect-metadata"; -import { container, DependencyContainer } from "tsyringe"; +import { container, DependencyContainer, Lifecycle } from "tsyringe"; // For the Vitest Custom Environment. import type { Environment } from "vitest"; @@ -11,6 +11,9 @@ import { IDatabaseTables } from "@spt-aki/models/spt/server/IDatabaseTables"; import { DatabaseServer } from "@spt-aki/servers/DatabaseServer"; import { ImporterUtil } from "@spt-aki/utils/ImporterUtil"; +//mocks +import { WinstonLogger } from "@tests/__mocks__/WinstonLogger.mock"; + export default { name: "spt-aki-server", transformMode: "ssr", @@ -20,6 +23,9 @@ export default { Container.registerTypes(container); Container.registerListTypes(container); + // Override registration to the container + container.register("WinstonLogger", WinstonLogger, { lifecycle: Lifecycle.Singleton }); + // Import the database. await importDatabase(container); diff --git a/project/tests/__mocks__/WinstonLogger.mock.ts b/project/tests/__mocks__/WinstonLogger.mock.ts new file mode 100644 index 00000000..8e4b2f35 --- /dev/null +++ b/project/tests/__mocks__/WinstonLogger.mock.ts @@ -0,0 +1,31 @@ +import { Daum } from "@spt-aki/models/eft/itemEvent/IItemEventRouterRequest"; +import { LogBackgroundColor } from "@spt-aki/models/spt/logging/LogBackgroundColor"; +import { LogTextColor } from "@spt-aki/models/spt/logging/LogTextColor"; +import { ILogger } from "@spt-aki/models/spt/utils/ILogger"; + +export class WinstonLogger implements ILogger +{ + writeToLogFile(data: string | Daum): void + { } + + log(data: string | Record | Error, color: string, backgroundColor?: string): void + { } + + logWithColor(data: string | Record, textColor: LogTextColor, backgroundColor?: LogBackgroundColor): void + { } + + error(data: string): void + { } + + warning(data: string): void + { } + + success(data: string): void + { } + + info(data: string): void + { } + + debug(data: string| Record, onlyShowInConsole?: boolean): void + { } +} diff --git a/project/vitest.config.ts b/project/vitest.config.ts index 0171332b..4d435ddc 100644 --- a/project/vitest.config.ts +++ b/project/vitest.config.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/naming-convention */ -import path from "path"; +import path from "node:path"; import { defineConfig } from "vitest/config"; export default defineConfig({