hardyscc / nestjs-dynamoose

Dynamoose module for Nest
MIT License
139 stars 24 forks source link

Mocking InjectModel providers #1096

Closed nircohLudeo closed 4 months ago

nircohLudeo commented 4 months ago

I'm using this library and trying to mock the provider injected by using @InjectModel("...") but I'm not sure how I should do it.


[ ] Regression 
[ ] Bug report
[x] Feature request
[] Documentation issue or request
[] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

No real way to mock the provided models

Expected behavior

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


NestJS version: X.Y.Z
NestJS Dynamoose version: X.Y.Z
Dynamoose version: X.Y.Z


For Tooling issues:
- Node version: XX  
- Platform:  

Others:

hardyscc commented 4 months ago

@nircohLudeo please check this project first https://github.com/hardyscc/aws-nestjs-starter, which contains 100% code coverage test case https://sonarcloud.io/component_measures?id=hardyscc_aws-nestjs-starter&metric=coverage&view=list

nircohLudeo commented 4 months ago

@nircohLudeo please check this project first https://github.com/hardyscc/aws-nestjs-starter, which contains 100% code coverage test case https://sonarcloud.io/component_measures?id=hardyscc_aws-nestjs-starter&metric=coverage&view=list

Sorry for the inconvenience, I figured out all I had to do was provide a mock using the name of the model service. In the example project you described I couldn't find a test for the notification.service but I have already managed. Sorry again!