UNPKG

@travetto/di

Version:

Dependency registration/management and injection support.

22 lines (20 loc) 601 B
import type { Class } from '@travetto/runtime'; import { Registry } from '@travetto/registry'; import { SuiteRegistryIndex } from '@travetto/test'; import { DependencyRegistryIndex } from '../../src/registry/registry-index.ts'; /** * Registers a suite as injectable * @kind decorator */ export function InjectableSuite() { return (cls: Class) => { SuiteRegistryIndex.getForRegister(cls).register({ beforeEach: [ async function (this: unknown) { await Registry.init(); await DependencyRegistryIndex.injectFields(this, cls); }, ] }); }; }