Successfully importing database and passing global container.
This commit is contained in:
parent
1eceb797e2
commit
f009d13d2a
@ -5,6 +5,7 @@ import NodeEnvironment from "jest-environment-node";
|
|||||||
import type { EnvironmentContext, JestEnvironmentConfig } from "@jest/environment";
|
import type { EnvironmentContext, JestEnvironmentConfig } from "@jest/environment";
|
||||||
|
|
||||||
import { Container } from "@spt-aki/di/Container";
|
import { Container } from "@spt-aki/di/Container";
|
||||||
|
import { DatabaseImporter } from "@spt-aki/utils/DatabaseImporter";
|
||||||
|
|
||||||
export default class CustomEnvironment extends NodeEnvironment
|
export default class CustomEnvironment extends NodeEnvironment
|
||||||
{
|
{
|
||||||
@ -17,7 +18,11 @@ export default class CustomEnvironment extends NodeEnvironment
|
|||||||
{
|
{
|
||||||
await super.setup();
|
await super.setup();
|
||||||
|
|
||||||
Container.registerTypes(container);
|
await Container.registerTypes(container);
|
||||||
|
|
||||||
|
const databaseImporter = container.resolve<DatabaseImporter>("DatabaseImporter");
|
||||||
|
await databaseImporter.onLoad();
|
||||||
|
|
||||||
this.global.container = container;
|
this.global.container = container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
import "reflect-metadata";
|
import "reflect-metadata";
|
||||||
|
|
||||||
import { ItemHelper } from "@spt-aki/helpers/ItemHelper";
|
import { ItemHelper } from "@spt-aki/helpers/ItemHelper";
|
||||||
|
import { DependencyContainer } from "tsyringe";
|
||||||
|
|
||||||
describe("ItemHelper", () =>
|
describe("ItemHelper", () =>
|
||||||
{
|
{
|
||||||
|
let container: DependencyContainer;
|
||||||
let itemHelper: ItemHelper;
|
let itemHelper: ItemHelper;
|
||||||
|
|
||||||
beforeAll(() =>
|
beforeAll(() =>
|
||||||
{
|
{
|
||||||
itemHelper = globalThis.container.resolve<ItemHelper>("ItemHelper");
|
container = globalThis.container;
|
||||||
|
itemHelper = container.resolve<ItemHelper>("ItemHelper");
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() =>
|
afterEach(() =>
|
||||||
|
Loading…
Reference in New Issue
Block a user