-
-
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
default moduleFileExtensions order is problematic for typescript projects #9834
Comments
The order of |
May I help this? thanks! |
Of course! 👍 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Hi. I think that the default order of extensions in moduleFileExtensions can be very problematic if you have typescript files in a project.
https://jestjs.io/docs/en/configuration#modulefileextensions-arraystring
As doc says, the lookup of module will have the order as set in this array.
This default order defines thet json files have precedence over ts files.
Why this can be problematic? Because sometimes you have both json and ts/js files of the same name.
For example if you use react-intl, you have messages.json next to messages.ts
This order breaks tests as file may
import { messages } from '[...]/i18n/messages';
As the result, the json file is loaded, not messages.ts. This causes improper module to be loaded during tests, causing all tests that use translations to fail.
I recommend to reorder extensions in default setup.
I think this will bring less problems than just mentioning
The text was updated successfully, but these errors were encountered: