Using customizers for jest configuration
I am trying to add a babel plugin to the jest configuration for my cra app.
My config-overrides file is exporting the advanced syntax:
module.exports = {
jest: (config) => {
// Do some stuff.
return config;
},
webpack: override(
// Using some customize-cra functions successfully.
),
}
I'm getting errors whenever I attempt to use override() with a customizer within the jest section:
<my-project>\node_modules\customize-cra\index.js:34
let loaders = config.module.rules.find(rule => Array.isArray(rule.oneOf))
It seems these functions expect a webpack config rather than a jest one?
Do any of your functions work with the jest configuration?
A workaround I found (and documented in my personal repo) is to add the jest configuration function as a property of the export.
So in your case, it would look something like
const options = override(...);
const jestConfig = (config) => {
// Do some stuff.
return config;
};
options.jest = jestConfig;
module.exports = options;
@mickelsonmichael Thanks for your reply. I don't quite remember what my goal was at the time, but I think I was hoping to actually use override() to combine customizers for jest specifically.
Yes it's definitely not an ideal solution, but hopefully it works for some while we wait for the proper overrides