Skip to content

Support property injection strategy for NestJS #64

@omermorad

Description

@omermorad

We wanted to inform you about an upcoming project that we'll be working on to enhance Automock. We will be adding support for properties injection alongside the existing constructor injection functionality.

This new addition will enable you to leverage properties injection as an alternative to constructor injection when managing dependencies in your classes. By utilizing the @Inject decorator, you'll be able to easily inject dependencies into class properties.

To provide you with an overview, here's an example of a class utilizing properties injection:

export class PropsBasedMainClass {
  @Inject(DependencyOne)
  private readonly dependencyOne: DependencyOne;

  @Inject(DependencyTwo)
  private readonly dependencyTwo: DependencyTwo;

  @Inject(forwardRef(() => DependencyThree))
  private readonly dependencyThree: DependencyThree;

  @Inject('CUSTOM_TOKEN')
  private readonly dependencyFour: DependencyFourToken;

  @Inject('LITERAL_VALUE_ARR')
  private readonly literalValueArray: string[];

  @Inject('LITERAL_VALUE_STR')
  private readonly literalValueString: string;
}

By incorporating properties injection, you'll have more flexibility in managing dependencies and configuring your classes within the Automock framework.

Your support and feedback are valuable, so please feel free to share any questions or suggestions you may have regarding this upcoming enhancement.

Thank you for your continued support.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions