Browse Source

Task/add dependency resolution test to app module spec (#8322)

Add dependency resolution test
pull/8323/head
Thomas Kaul 24 hours ago
committed by GitHub
parent
commit
9827aba677
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 20
      apps/api/src/app/app.module.spec.ts

20
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<DynamicModule> | 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();
}
});
});

Loading…
Cancel
Save