-
Notifications
You must be signed in to change notification settings - Fork 363
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
Jest: Cannot find module '@lingui/loader!locales/de/messages.po' #1304
Comments
You either should compile your catalogs beforehand with Something like (I did not test that): /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
moduleNameMapper: {
'^@lingui/loader!': '<rootDir>/path/to/mock',
},
// ...
}; |
@andrii-bodnar I think some action points still needed here. Indeed if you use loader (webpack/snowpack/vite/etc) and don't have explicit compile step in your pipeline it is not that straightforward how to setup testing with jest. Compile catalogs before running tests and have separate setup for loading? Looks very complicated. I would suggest implement official transformer for jest the same way as loader works to be more aligned with the rest of tooling. |
@thekip thanks for the details! Reopened the issue |
@thekip is addressing this still on the roadmap? Thanks! |
Not really. I personally test only with default language, others could just mock catalogs with stubs to make tests more independent of translations and thus more reliable. So i think using a transformer to compile catalogs in Jest would bring more harm them help. |
Describe the bug
When running a test using
jest
it fails to import the message catalog and throws the following errorTo Reproduce
Expected behavior
That the
message.po
catalog is imported without any error@lingui/loader@3.8.10
jest@29.0.3
@babel/core@7.14.3
The text was updated successfully, but these errors were encountered: