Successfully importing database and passing global container.

This commit is contained in:
Refringe 2023-10-26 17:19:16 -04:00 committed by TheSparta
parent 1eceb797e2
commit f009d13d2a
2 changed files with 10 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import NodeEnvironment from "jest-environment-node";
import type { EnvironmentContext, JestEnvironmentConfig } from "@jest/environment";
import { Container } from "@spt-aki/di/Container";
import { DatabaseImporter } from "@spt-aki/utils/DatabaseImporter";
export default class CustomEnvironment extends NodeEnvironment
{
@ -17,7 +18,11 @@ export default class CustomEnvironment extends NodeEnvironment
{
await super.setup();
Container.registerTypes(container);
await Container.registerTypes(container);
const databaseImporter = container.resolve<DatabaseImporter>("DatabaseImporter");
await databaseImporter.onLoad();
this.global.container = container;
}

View File

@ -1,14 +1,17 @@
import "reflect-metadata";
import { ItemHelper } from "@spt-aki/helpers/ItemHelper";
import { DependencyContainer } from "tsyringe";
describe("ItemHelper", () =>
{
let container: DependencyContainer;
let itemHelper: ItemHelper;
beforeAll(() =>
{
itemHelper = globalThis.container.resolve<ItemHelper>("ItemHelper");
container = globalThis.container;
itemHelper = container.resolve<ItemHelper>("ItemHelper");
});
afterEach(() =>