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]: Add ability to pass config to presets #4200

Open
bfricka opened this issue Aug 28, 2023 · 0 comments
Open

[Feature]: Add ability to pass config to presets #4200

bfricka opened this issue Aug 28, 2023 · 0 comments

Comments

@bfricka
Copy link

bfricka commented Aug 28, 2023

馃殌 Feature Proposal

With v29 deprecating ts-jest in globals, it's now nearly impossible to both use a preset and pass options. Presets are just recipes and extending them should be trivial. To pass options, we currently would have to copy the recipe (which mostly defeats the purpose), and then add our custom options, or do some crazy remapping of the preset values, adding our config that way.

It's actually pretty surprising to me that this was released with no way to extend presets, and the docs have both a page for Presets and a page for Options, and the two cannot be made to work together.

This could be accommodated by add a withOptions function on each preset that's basically a factory for creating the preset with the options merged in.

const { jsWithTs } = require('ts-jest/presets')

///
{
  transform: jsWithTs.withOptions(opts).transform,
}

If there's a better way, I'd love to hear it. Thank you.

Motivation

My motivation is to make it trivial to add options to presets, thereby making them useful again in cases where a tsconfig path or some other option needs to be adjusted.

Example

No response

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

No branches or pull requests

1 participant