2023-10-26 20:12:19 +02:00
|
|
|
import "reflect-metadata";
|
2023-10-26 22:01:38 +02:00
|
|
|
import { container } from "tsyringe";
|
2023-10-26 20:12:19 +02:00
|
|
|
|
|
|
|
import NodeEnvironment from "jest-environment-node";
|
2023-10-26 22:01:38 +02:00
|
|
|
import type { EnvironmentContext, JestEnvironmentConfig } from "@jest/environment";
|
2023-10-26 20:12:19 +02:00
|
|
|
|
|
|
|
import { Container } from "@spt-aki/di/Container";
|
2023-10-26 23:19:16 +02:00
|
|
|
import { DatabaseImporter } from "@spt-aki/utils/DatabaseImporter";
|
2023-10-26 20:12:19 +02:00
|
|
|
|
2023-10-26 22:01:38 +02:00
|
|
|
export default class CustomEnvironment extends NodeEnvironment
|
2023-10-26 20:12:19 +02:00
|
|
|
{
|
|
|
|
constructor(config: JestEnvironmentConfig, context: EnvironmentContext)
|
|
|
|
{
|
|
|
|
super(config, context);
|
|
|
|
}
|
|
|
|
|
|
|
|
async setup(): Promise<void>
|
|
|
|
{
|
|
|
|
await super.setup();
|
|
|
|
|
2023-10-26 23:19:16 +02:00
|
|
|
await Container.registerTypes(container);
|
|
|
|
|
|
|
|
const databaseImporter = container.resolve<DatabaseImporter>("DatabaseImporter");
|
|
|
|
await databaseImporter.onLoad();
|
|
|
|
|
2023-10-26 20:12:19 +02:00
|
|
|
this.global.container = container;
|
|
|
|
}
|
|
|
|
|
|
|
|
async teardown(): Promise<void>
|
|
|
|
{
|
|
|
|
await super.teardown();
|
|
|
|
}
|
|
|
|
}
|