typeorm icon indicating copy to clipboard operation
typeorm copied to clipboard

InjectRepository fails when running test

Open osmanmesutozcan opened this issue 7 years ago • 7 comments

I'm submitting a...


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

Current behavior

@InjectRepository fails with 'TypeError: Right-hand side of 'instanceof' is not an object'. when yarn test

Expected behavior

Minimal reproduction of the problem with instructions

https://github.com/osmanmesutozcan/nestjs-inject-repository-bug-repro

to run it:

yarn
yarn test

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

Environment


Nest version: 
    "@nestjs/common": "^5.4.0",
    "@nestjs/core": "^5.4.0",
    "@nestjs/graphql": "^5.5.7",
    "@nestjs/typeorm": "^5.3.0",

 
For Tooling issues:
- Node version: 10.12.0  
- Platform: Linux  

Others:

osmanmesutozcan avatar Mar 09 '19 08:03 osmanmesutozcan

Please, provide a minimal repository which reproduces your issue.

kamilmysliwiec avatar Mar 09 '19 18:03 kamilmysliwiec

Hey @kamilmysliwiec. I actually did add an example repository. Let me know if it needs some more clarification.

yarn test should pop an error message

osmanmesutozcan avatar Mar 09 '19 21:03 osmanmesutozcan

Looks more like a Jest configuration problem

rcanessa89 avatar Mar 29 '19 19:03 rcanessa89

Sounds like you were passing undefined to @InjectRepository. I added an additional check in 6.1.0

kamilmysliwiec avatar Apr 15 '19 12:04 kamilmysliwiec

Would you guys give more detail of this? I'm having this problem. How do we fix that?

angel-carvajal avatar Feb 06 '20 05:02 angel-carvajal

Same problem here... Some solution?

wm4tos avatar Feb 13 '20 18:02 wm4tos

I would suggest avoiding barrel files (index.ts). This may cause some side-effects, leading to classes being represented as undefined. It's especially important when it comes to jest and it's path resolution mapper.

kamilmysliwiec avatar Feb 13 '20 18:02 kamilmysliwiec