Cannot seem to mock a class that has the @InjectRepository by mikro-orm or because of its generic typing #268
-
I have the following code in my test: const { unit, unitRef } = TestBed.create(MyService)
.compile();
myService = unit;
myRepository = unitRef.get(EntityRepository<MyEntity>); and the following code shows the constructor of constructor(
@InjectRepository(MyEntity)
private myRepository: EntityRepository<MyEntity>,
) {} I currently get an |
Beta Was this translation helpful? Give feedback.
Answered by
omermorad
Jan 18, 2024
Replies: 1 comment 1 reply
-
Are you using NestJS as your framework? const { unit, unitRef } = TestBed.create(MyService).compile();
myService = unit;
myRepository = unitRef.get(getRepositoryToken(EntityRepository) as string); Let's me know if it worked. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
rienheuver
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Are you using NestJS as your framework?
Try use this:
Let's me know if it worked.