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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Support loading jest.config.ts as ESM #13118

Open
luxaritas opened this issue Aug 11, 2022 · 6 comments
Open

[Feature]: Support loading jest.config.ts as ESM #13118

luxaritas opened this issue Aug 11, 2022 · 6 comments

Comments

@luxaritas
Copy link

馃殌 Feature Proposal

  • If "type": "module" is set in the package.json, jest.config.ts should be treated as ESM, not CJS
  • jest.config.mts and jest.config.cts should be looked for and loaded as ESM and CJS, respectively

Motivation

  • This is currently the behavior with jest.config.js, and so ESM vs CJS handling differs between JS and TS configs
  • I would like to be able to import ESM libraries in my TS config

Example

No response

Pitch

  • Config loading is handled by core
  • Module behavior between JS and TS should match
@luxaritas
Copy link
Author

Related: #11453

@SimenB
Copy link
Member

SimenB commented Aug 12, 2022

@SimenB
Copy link
Member

SimenB commented Aug 12, 2022

That said, I don't think anything has changed since #11453 (comment) (i.e. you need a loader). But we should at least find cts as that is supposed to be converted to cjs

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@karlhorky
Copy link
Contributor

karlhorky commented Apr 12, 2023

@SimenB as a first step, maybe let's get support for jest.config.cts, to avoid the extra ts-node.moduleTypes config for ts-node

Took a quick shot at a PR - does it need anything else? (other than fixing the tests)

Edit: @DerTimonius opened a new PR based on mine, which also fixes the tests:

@SimenB
Copy link
Member

SimenB commented Feb 20, 2024

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

No branches or pull requests

3 participants