import { INestApplication, Provider, Type } from '@nestjs/common' type GetApp = () => INestApplication // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type type TypeOrToken = string | symbol | Function | Type export class TestModuleRef { static Provider(getApp: GetApp): Provider { return { provide: TestModuleRef, useFactory: () => new TestModuleRef(getApp), } } constructor(protected getApp: GetApp) {} public async resolve(typeOrToken: TypeOrToken): Promise { return this.getApp()?.resolve(typeOrToken) } public get(typeOrToken: TypeOrToken): T { return this.getApp().get(typeOrToken) } }