Join GitHub today
JSON files are not transformed via custom preprocessor #2578
Report a bug
Jest is ignoring JSON files for applying custom preprocessors via the
What is the current behavior?
A JSON file source is never sent to a custom preprocessor configured to transform its source. Other files (e.g. XML) are sent properly to the preprocessor.
Reproduceable with the files from: https://gist.github.com/avaly/3ff041228a5c6f789119170c28a80367
What is the expected behavior?
The JSON file source should be sent to the preprocessor.
Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
@cpojer This would be one example of issues of running Jest instead of running tests in a browser environment, where we can apply webpack's
Hi, We just got hit by this issue while trying to migrate to Jest. Is there any patch or fix posible?
How would we about to make a fix/change to allow transform for JSON files?
Can we know which part of the code handle this default so we can take a look and try to fix or amplify the behavior
referenced this issue
Oct 8, 2018
@cpojer Is this still the intended design, that JSON files cannot be transformed?
I'm working on an i18n solution for me team that involves a webpack plugin that transforms the localized string JSON (and extracts the translations on a per-bundle basis). The transformed JSON is then passed to a function in the resulting web client code for localization to the appropriate locale.
Without the ability to implement a Jest transform, I'm going to have to deal with devs on my team who are confused why they can't mock the localization function in the expected manner.