Skip to content

Cannot seem to mock a class that has the @InjectRepository by mikro-orm or because of its generic typing #268

Answered by omermorad
rienheuver asked this question in Q&A
Discussion options

You must be logged in to vote

Are you using NestJS as your framework?
Try use this:

const { unit, unitRef } = TestBed.create(MyService).compile();
myService = unit;
myRepository = unitRef.get(getRepositoryToken(EntityRepository) as string);

Let's me know if it worked.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rienheuver
Comment options

Answer selected by rienheuver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants