Skip to content
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

Using customizers for jest configuration #326

Open
kenlyon opened this issue Jun 3, 2022 · 3 comments
Open

Using customizers for jest configuration #326

kenlyon opened this issue Jun 3, 2022 · 3 comments

Comments

@kenlyon
Copy link

kenlyon commented Jun 3, 2022

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?

@mickelsonmichael
Copy link

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;

@kenlyon
Copy link
Author

kenlyon commented Jul 11, 2023

@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.

@mickelsonmichael
Copy link

Yes it's definitely not an ideal solution, but hopefully it works for some while we wait for the proper overrides

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants