Skip to content

Commit

Permalink
fix: Module id generatorAlgorithm can't be controlled in test #14455
Browse files Browse the repository at this point in the history
  • Loading branch information
rbnayax committed Jan 19, 2025
1 parent 4ef49ce commit 817ede3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 10 additions & 2 deletions packages/testing/test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import { ModuleMetadata } from '@nestjs/common/interfaces/modules/module-metadata.interface';
import { MetadataScanner } from '@nestjs/core/metadata-scanner';
import { TestingModuleBuilder } from './testing-module.builder';
import { NestApplicationContextOptions } from '@nestjs/common/interfaces/nest-application-context-options.interface';

export class Test {
private static readonly metadataScanner = new MetadataScanner();

public static createTestingModule(metadata: ModuleMetadata) {
return new TestingModuleBuilder(this.metadataScanner, metadata);
public static createTestingModule(
metadata: ModuleMetadata,
contextOptions: NestApplicationContextOptions | undefined = undefined,
) {
return new TestingModuleBuilder(
this.metadataScanner,
metadata,
contextOptions,
);
}
}
4 changes: 3 additions & 1 deletion packages/testing/testing-module.builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { TestingModule } from './testing-module';
*/
export class TestingModuleBuilder {
private readonly applicationConfig = new ApplicationConfig();
private readonly container = new NestContainer(this.applicationConfig);
private readonly container: NestContainer;
private readonly overloadsMap = new Map();
private readonly moduleOverloadsMap = new Map<
ModuleDefinition,
Expand All @@ -41,7 +41,9 @@ export class TestingModuleBuilder {
constructor(
private readonly metadataScanner: MetadataScanner,
metadata: ModuleMetadata,
contextOptions: NestApplicationContextOptions | undefined = undefined,
) {
this.container = new NestContainer(this.applicationConfig, contextOptions);
this.module = this.createModule(metadata);
}

Expand Down

0 comments on commit 817ede3

Please sign in to comment.