we are using jest on a react typescript project. If there is a babel.config.js with preset: [@babel/preset-env] the test running successfully. But with the existence of that babel file our next.js web project is not compiling any more.
How can I setup this babel.config.js only for jest and not for next.js?
See Making your Babel config jest-aware
Jest will set process.env.NODE_ENV to 'test' if it's not set to something else. You can use that in your configuration to conditionally setup only the compilation needed for Jest, e.g.
babel.config.js:
module.exports = api => {
const isTest = api.env('test');
// You can use isTest to determine what presets and plugins to use.
return {
// ...
};
};