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.(cjs|mjs|ts) as a Jest configuration file for packages written in ESM #1020

Open
karlhorky opened this issue Apr 23, 2021 · 1 comment
Labels
kind: feature New feature or request progress: blocked scope: upstream Issue in upstream dependency

Comments

@karlhorky
Copy link
Contributor

Current Behavior

If a package is written in ESM, the only way to configure Jest is via the "jest" field in the package.json file.

Desired Behavior

It would be nice to also be able to use the standard jest.config.(cjs|mjs|ts) files.

Suggested Solution

Read from the jest.config.cjs file (and any other config files that Jest resolves, such as jest.config.mjs and jest.config.ts)

Who does this impact? Who is this for?

TSDX users who would like to write their Jest config in the standard ways.

Describe alternatives you've considered

Don't do anything

Additional context

#187

@agilgur5
Copy link
Collaborator

agilgur5 commented Apr 11, 2022

Known issue, trust me when I say if it were easy, I would have supported it a long time ago. Can see #526 (review) where I lament about Jest's lack of programmatic API. jestjs/jest#5048 is still open and due to this TSDX had to implement custom parsing code for Jest configs.

Could support CJS with a few LoC as it's just another filename, but would have to detect it. MJS could potentially be possible in a similar manner once Node 10 is dropped (might be some compat issues there though).
TS is highly non-trivial without a Jest API exposed. Jest's own code basically checks if it's a TS file, then checks if you have ts-node installed, then uses ts-node to load the file. That also adds another big dep on top of that complexity and changing up the loader chain and TS versioning etc. Similar thing for say tsdx.config.ts -- it adds quite a bit of complexity for such a small feature

#187

That issue is unrelated to reading jest.config files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: feature New feature or request progress: blocked scope: upstream Issue in upstream dependency
Projects
None yet
Development

No branches or pull requests

2 participants