Override WinstonLogger registration with a mock
This commit is contained in:
parent
946552199e
commit
e327df7504
@ -1,5 +1,5 @@
|
|||||||
import "reflect-metadata";
|
import "reflect-metadata";
|
||||||
import { container, DependencyContainer } from "tsyringe";
|
import { container, DependencyContainer, Lifecycle } from "tsyringe";
|
||||||
|
|
||||||
// For the Vitest Custom Environment.
|
// For the Vitest Custom Environment.
|
||||||
import type { Environment } from "vitest";
|
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 { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
||||||
import { ImporterUtil } from "@spt-aki/utils/ImporterUtil";
|
import { ImporterUtil } from "@spt-aki/utils/ImporterUtil";
|
||||||
|
|
||||||
|
//mocks
|
||||||
|
import { WinstonLogger } from "@tests/__mocks__/WinstonLogger.mock";
|
||||||
|
|
||||||
export default <Environment> {
|
export default <Environment> {
|
||||||
name: "spt-aki-server",
|
name: "spt-aki-server",
|
||||||
transformMode: "ssr",
|
transformMode: "ssr",
|
||||||
@ -20,6 +23,9 @@ export default <Environment> {
|
|||||||
Container.registerTypes(container);
|
Container.registerTypes(container);
|
||||||
Container.registerListTypes(container);
|
Container.registerListTypes(container);
|
||||||
|
|
||||||
|
// Override registration to the container
|
||||||
|
container.register<WinstonLogger>("WinstonLogger", WinstonLogger, { lifecycle: Lifecycle.Singleton });
|
||||||
|
|
||||||
// Import the database.
|
// Import the database.
|
||||||
await importDatabase(container);
|
await importDatabase(container);
|
||||||
|
|
||||||
|
31
project/tests/__mocks__/WinstonLogger.mock.ts
Normal file
31
project/tests/__mocks__/WinstonLogger.mock.ts
Normal file
@ -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<string, unknown> | Error, color: string, backgroundColor?: string): void
|
||||||
|
{ }
|
||||||
|
|
||||||
|
logWithColor(data: string | Record<string, unknown>, 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<string, unknown>, onlyShowInConsole?: boolean): void
|
||||||
|
{ }
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable @typescript-eslint/naming-convention */
|
/* eslint-disable @typescript-eslint/naming-convention */
|
||||||
import path from "path";
|
import path from "node:path";
|
||||||
import { defineConfig } from "vitest/config";
|
import { defineConfig } from "vitest/config";
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
Loading…
Reference in New Issue
Block a user