jest.config.js is using commonjs. Can we use jest.config.mjs and jest.config.cjs for config file in node 13.2?
esm support for config file
// jest.config.mjs
export default {
// [...]
// Replace `ts-jest` with the preset you want to use
// from the above list
preset: 'ts-jest/presets/js-with-ts',
};
Why does this feature belong in the Jest core platform?
Common feature proposals that do not typically make it to core:
this is pretty much blocked by #4842.
@SimenB jest.config.cjs is not blocked by experimental-loader API.
Does it make sense to add support for this, which is useless outside of esm support in node (which we don't support)? It's simple enough in isolation, but I'm not sure it provides much value, and might confuse users more? thoughts?
@SimenB Yes, it does. I have type=module packages and use Jest+Babel to run tests. But Node 13 refuses to load .js files inside such packages, which means that Jest fails to open a .js config. Moreover, you can't manually point to a .cjs file because of a check in readConfigs(). I've made a similar request in #9086.
Most helpful comment
@SimenB Yes, it does. I have
type=modulepackages and use Jest+Babel to run tests. But Node 13 refuses to load.jsfiles inside such packages, which means that Jest fails to open a.jsconfig. Moreover, you can't manually point to a.cjsfile because of a check inreadConfigs(). I've made a similar request in #9086.