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

Build a JS based .jestrc config system. #2203

Closed
mohsen1 opened this issue Dec 1, 2016 · 13 comments

Comments

@mohsen1
Copy link

commented Dec 1, 2016

Following from here: kulshekhar/ts-jest#64

The TypeScript config defines a baseUrl option that is root for resolving modules. Can a processor provide the baseUrl from TSConfig as an additional moduleDirectories option?

@cpojer

This comment has been minimized.

Copy link
Contributor

commented Dec 1, 2016

No it cannot currently and that would be pretty odd. It seems like it would make more sense for the Jest config to read the ts config and add that from the beginning. This may be a compelling reason to allow JS based config files. What do you think?

@mohsen1

This comment has been minimized.

Copy link
Author

commented Dec 1, 2016

Thanks for quick feedback!

]A programmable config file is going to solve this problem. Repeating the module roots in jest config and tsconfig isn't ideal.

@cpojer

This comment has been minimized.

Copy link
Contributor

commented Dec 1, 2016

At the same time they don't change often, do they? It may just be fine :)

If you'd like to send a PR to Jest, this should be somewhere in packages/jest-config. We've been meaning to support something like .jestrc for the longest time.

@ericclemmons

This comment has been minimized.

Copy link
Contributor

commented Dec 1, 2016

@cpojer I just searched these issues for .jestrc (only --config .jestrc works today it seems!)

How can I help support that?

@cpojer

This comment has been minimized.

Copy link
Contributor

commented Dec 1, 2016

Add support to jest-config. There is some "loadConfigFromPackage" or something functionality in there so I'd change the resolution to something like:

  • Load config from file that was passed in.
  • Load config from jestrc (preferred) or package.json at the closest location by walking up to the root.

What do you think?

@ericclemmons

This comment has been minimized.

Copy link
Contributor

commented Dec 1, 2016

Makes sense to me. I know I've seen this done similarly in Babel:

https://github.com/babel/babel/blob/master/packages/babel-core/src/transformation/file/options/build-config-chain.js

The only difference is that jest wouldn't merge configs, but would use the single, closest config to the test file.

Cool?

@cpojer

This comment has been minimized.

Copy link
Contributor

commented Dec 1, 2016

Yes, I agree. I think we should prioritize jestrc over package.json and that's fine.

@cpojer cpojer changed the title Can a processor provide more `moduleDirectories`? Build a JS based .jestrc config system. Dec 14, 2016

@yoavniran

This comment has been minimized.

Copy link
Contributor

commented Dec 15, 2016

hi @cpojer - following up from #2320 - I would love to help with this, definitely.

Im just wondering, as im trying to solve a problem for JSPM/SystemJS users that requires reading the config and providing both 'moduleDirectories' and 'moduleNameMapper' jest config values how do you envision it happening with a .jestrc file?
do you see it being loaded as a node module so can hold its own logic?

@cpojer

This comment has been minimized.

Copy link
Contributor

commented Dec 15, 2016

yes, .jestrc would simply be a JavaScript file that exports the config.

@stephencookdev

This comment has been minimized.

Copy link
Contributor

commented Dec 26, 2016

Would love to see this feature added too! Would appreciate thoughts on what you guys think of #2445 to add this functionality

@cpojer

This comment has been minimized.

Copy link
Contributor

commented Dec 28, 2016

Thanks for the PR! I'll look at this in about a week when I get back to the office :)

@ArmorDarks

This comment has been minimized.

Copy link

commented Feb 15, 2017

One more fella from JSPM users camp here. Would be great to see this implemented!

@cpojer

This comment has been minimized.

Copy link
Contributor

commented May 2, 2017

This will be in Jest 20, soon.

@cpojer cpojer closed this May 2, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.