ESModules + ts-jest = Must use import to load ES Module: ****src/db/entities/****.entity.ts #5461
artsiommiksiuk
started this conversation in
General
Replies: 1 comment 1 reply
-
Hmm, I guess I completely forgot people still use jest even with ESM projects - that's because it was nearly impossible to set up some time ago :D (also, vitest just works - use that if your project is ESM, and thank me later! although that would also mean you need ts-morph to get the decorator metadata, or specify types explicitly) Let's see if it won't backfire, removed the whole |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Describe the bug
Using ESModules with ts-jest and trying to initialize mikro orm, causes autodiscovery to throw this with the error in the title.
Following the stack trace, I've stumbled to this:
mikro-orm/packages/core/src/utils/Utils.ts
Line 1072 in 7fc4354
I removed
process.env.TS_JEST
check and discovery passed and tests were executed.I'm assuming there should be additional check, that it's not only TS_JEST env, but also that project is not in ESM mode.
Reproduction
I have quite complex setup, not sure I can reproduce.
Here's stack trace:
What driver are you using?
@mikro-orm/sqlite
MikroORM version
6.2.0
Node.js version
20.11.1
Operating system
MacOS
Validations
Beta Was this translation helpful? Give feedback.
All reactions