New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MikroORM does not discover entities when running from jest in my nestjs app #2006
Comments
It works fine for me, this is not enough to reproduce anything.
Well, then just upgrade, that lock file is very outdated. Always first upgrade to latest before filing a bug report. Also that second error when you build the app points to using different entity than you discover, in other words, you discover JS entity but execute via ts-node or vice versa. You always need to discover the same files you will use - so for ts-node you need to discover TS files from src, for node you need to discover JS files from dist. Closing this, as there is nothing to reproduce and this is definitely just a misconfiguration. Will update the example project and add a CI pipeline to make sure it works fine, but again, I am using the project locally quite often and it works just fine. Worth nothing that sometimes you need to explicitly enable the TS mode in the ORM config as it might not be detected properly. But for me that works also just fine in that project - maybe you are on a different platform (I am on macos and CI works on ubuntu). So if you want to run the tests in TS mode and it is not detected properly, just add |
Ok so apparently this is working fine on macos but not on linux as the CI failed - but still, what I said above applies, correct way is to enfore TS mode via |
Hi! Odd. I am on MacOS Big Sur. Adding the Thanks! |
Apparently it was not working even for me, but the tests were passing because I had the project built and the test did not really required anything ORM specific to pass, so discovering JS files was enough. Anyway, asked the ts-jest guys if we can detect this somehow, and apparently we can't, so I PR'ed it (kulshekhar/ts-jest#2717) - expect some future ts-jest and MikroORM versions to support this automatically :] |
I get a
MetadataError: No entities were discovered
when I try to use jest to run my tests.If I build first, then MikroORM seems to be able to discover my entities from my
dist
directory. But I get aI am able to reproduce the
No entities were discovered
issue with https://github.com/mikro-orm/nestjs-realworld-example-app when I try to runyarn test
yTo Reproduce
Steps to reproduce the behavior:
yarn test
Expected behavior
I expect the tests to run with entities discovered from my
src
directory as thedist
entities may not be current.Versions
Using the versions specified in the yarn.lock
The text was updated successfully, but these errors were encountered: