support jest.config.mjs and jest.config.cjs
See original GitHub issue🚀 Feature Proposal
jest.config.js
is using commonjs. Can we use jest.config.mjs
and jest.config.cjs
for config file in node 13.2?
Motivation
esm support for config file
Example
// 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',
};
Pitch
Why does this feature belong in the Jest core platform?
Common feature proposals that do not typically make it to core:
- New matchers (see jest-extended)
- Changes to the default reporter (use custom reporters instead)
- Changes to node/jsdom test environments (use custom environments instead)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Configuring Jest
It is recommended to define the configuration in a dedicated JavaScript, TypeScript or JSON file. The file will be discovered automatically, if it...
Read more >How to import ".mjs" modules in Jest's xyz.test.js?
I think it would work with following setup: At root level of your app, jest.config.js : module.exports = { testRegex: "(/__tests__/.*|(\\.
Read more >Presets | ts-jest - GitHub Pages
If you are using custom transform config, please remove preset from your Jest config to avoid issues that Jest doesn't transform files correctly....
Read more >babel-jest - Awesome JS
[jest-config] Do not warn about preset in ProjectConfig #13583 ... [jest-runtime] Properly support CJS re-exports from dual packages (#13170) ...
Read more >Config Files - Babel.js
cjs allow you to define your configuration as CommonJS, using module.exports . They have been supported since v7.7.0 . babel.config.mjs and .babelrc.mjs ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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 inreadConfigs()
. I’ve made a similar request in #9086.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?