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

support jest.config.mjs and jest.config.cjs #9225

Closed
xiaoxiangmoe opened this issue Nov 23, 2019 · 5 comments · Fixed by #9431
Closed

support jest.config.mjs and jest.config.cjs #9225

xiaoxiangmoe opened this issue Nov 23, 2019 · 5 comments · Fixed by #9431

Comments

@xiaoxiangmoe
Copy link

xiaoxiangmoe commented Nov 23, 2019

🚀 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)
@xiaoxiangmoe xiaoxiangmoe changed the title support jest.config.mjs support jest.config.mjs and jest.config.cjs Nov 23, 2019
@SimenB
Copy link
Member

SimenB commented Nov 23, 2019

this is pretty much blocked by #4842.

@xiaoxiangmoe
Copy link
Author

@SimenB jest.config.cjs is not blocked by experimental-loader API.

@SimenB
Copy link
Member

SimenB commented Nov 25, 2019

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?

@the-spyke
Copy link
Contributor

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

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants