-
I'm trying to inject automapper when creating a testing module, but i'm getting an error because Mapper is an interface not a class.
I'm using the library with NestJS |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
@bfahm You should use If you use I can update docs ASAP to mention this. Thank you for asking! |
Beta Was this translation helpful? Give feedback.
-
Hey, I've run into this issue as well and the above answer by @nartc worked for me in terms of getting the dependency resolving, but how do we go about mocking the actual map() function? I have a profile with 2 different mappings like so `@Injectable() mapProfile(): MappingProfile { and my mockLoanMapper: export const mockLoanMapper = { but how do I mock the map function to return the correct object given that the mapping function depends on the types specified. Like if the map function is called with the mockLoan object of type Loan, i want the mockLoanResponseDto to be returned. But if the map() function is called with the mockLoanInputDto, I want the map function to return the mockLoan object. |
Beta Was this translation helpful? Give feedback.
@bfahm You should use
getMapperToken()
utility for theprovide
there.If you use
InjectMapper('name_goes_here')
then use{ provide: getMapperToken('name_goes_here'), .. }
.If you use
InjectMapper()
then use{ provide: getMapperToken(), ... }
I can update docs ASAP to mention this. Thank you for asking!