diff --git a/apps/api/src/app/app.module.spec.ts b/apps/api/src/app/app.module.spec.ts index 27e11ea919..d43caf8c46 100644 --- a/apps/api/src/app/app.module.spec.ts +++ b/apps/api/src/app/app.module.spec.ts @@ -20,6 +20,7 @@ import { import { VersionValue } from '@nestjs/common/interfaces'; import { MetadataScanner } from '@nestjs/core'; import { AuthGuard } from '@nestjs/passport'; +import { Test } from '@nestjs/testing'; import { isUndefined, omitBy } from 'lodash-es'; import { AppModule } from './app.module'; @@ -32,6 +33,13 @@ jest.mock('ai', () => { return {}; }); +// A queue of Bull connects to Redis on its creation +jest.mock('bull', () => { + return jest.fn().mockImplementation(() => { + return { close: jest.fn() }; + }); +}); + type ModuleDefinition = DynamicModule | ForwardReference<() => Type> | Promise | Type; @@ -334,4 +342,16 @@ describe('AppModule', () => { expect(new Set(routes).size).toBe(routes.length); expect(Object.fromEntries(routesWithSecurity)).toMatchSnapshot(); }); + + it('should resolve the dependencies of each provider', async () => { + const testingModule = await Test.createTestingModule({ + imports: [AppModule] + }).compile(); + + try { + expect(testingModule.get(AppModule)).toBeInstanceOf(AppModule); + } finally { + await testingModule.close(); + } + }); });