-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
globalSetup, globalTeardown and testEnvironment does not recognize moduleNameMappers config #11644
Comments
I can share that I am facing the same issue. For my case, I am importing another module which uses aliases in the module defined for |
oh damn. this just cost me several hours. |
Having the same issue. |
Please solve it |
Having the same issue, any plan for this point? |
This is such a frustrating bug, with But unfortunately its not usable in a modern TS application, as pretty much every app will be using either Therefore the So as it currently stands this bug is blocking out this feature for TS jest users |
Any information on whether this is being fixed? |
1 similar comment
Any information on whether this is being fixed? |
Hello fellow developer who spent Install tsconfig-paths and add |
i also just run into this while trying to change my code work for both CJS and ESM (because ESM requires explicit endings, but those files do not exist when using using jest 28 |
|
Bumping this. It's really confusing. The one-liner fix suggested in #11644 (comment) works well. This should be the built-in behavior. |
hello folks. Adding |
tsconfig-paths can be quite finicky when combined with Jest as it can take priority over Jest's transformers. |
Just figured out I can add |
I had the same problem, this comment solved it. |
Helpful. |
Working on an older project that isn't Typescript related, and also running into the same issue. |
Still running into the same issue, even with |
same issue here, typescript is great but all typescript ecosystem is pure insanity |
Hello, same issue here, this one-liner still fixes it. |
|
If The fix is to set the process.env.TS_NODE_PROJECT = 'tsconfig.base.json';
import 'tsconfig-paths/register'; |
As noted in this commend: jestjs/jest#11644 (comment) And this comment: #1107 (comment)
🐛 Bug Report
Modules defined in
globalSetup
,globalTeardown
and intestEnvironment
are not being recognized bymoduleNameMappers
(and maybe others liketransform
). I think this may be a bug, otherwise consider this as a feature request.This is maybe related to #5164 and #6179
To Reproduce
globalSetup
,globalTeardown
ortestEnvironment
files;Cannot find module '<module alias>'
error should appear.Expected behavior
globalSetup
,globalTeardown
ortestEnvironment
files should import modules defined onmoduleNameMappers
config.Link to repl or repo
jest.config.js
uncommentglobalSetup
,globalTeardown
ortestEnvironment
config entries;npm run test
https://codesandbox.io/s/jest-module-alias-bug-v3wij
envinfo
The text was updated successfully, but these errors were encountered: