-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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 .jestrc #2445
Support .jestrc #2445
Conversation
@stephencookdev are you still planning to work on this feature? |
Yes - I'd forgotten about this a bit tbh I'm just looking at resolving the merge conflicts and build issue now, and then I'll try and chase people up to review the code. #1206 in a follow-up PR would be awesome, yeah - I fear it might be a bit more of an involved change than this PR (as this PR is just adding an extra config source, rather than changing the way config gets applied to each test suite); but still worth doing :) |
Awesome! Thank you |
@cpojer just pinging for a review in case it fell off your radar :) I'll try to get some unit-tests up and running for the feature tonight, and having a quick think about what the work to do to get us to #1204 is tonight But would be great to just have the business-logic of what I've done in this PR confirmed before I get too far into any of that :) |
Wow, that seems to be great addition! Thanks for your work, @stephencookdev Hope this PR will be reviewed by @cpojer soon... |
Ping @cpojer? Can you at least let us know do you plan to merge it? Thanks! |
Currently I'm undecided. I'm not against it but I don't see the clear value proposition yet. There is also a larger issue about a multi-config runner #2970 which may have implications. |
Thanks for reply @cpojer! Usecase is quite straightforward — when you need to dynamically configure certain parts of Jest based on certain conditions, like current environment. Another important usecase is passing JSPM\SystemJS mappings to Jest directly within configuration file, without need to hack around with additional build steps (which results in quite bad development experience). Sometimes you do not want to pollute Finally, by this day it is almost de facto standard to provide possibility of configuration through external rc file. Just for the information, ESLint uses same approach with configuration file and allows to specify |
Another use case I can think of would be to potentially leverage this for the jest-editor-support code. We are currently passing some information through via command line flags to override parameters in the config file. But it would be even easier and scale better over time to just provide a |
I reviewed mentioned #2970, but it seems to be related very partially. This PR solves particular issue — it brings current JS configs declaration standards into Jest. #2970 on contrary sounded to me like an issue about solving particular issues in Facebook repositories (yeap, despite it tries so hard to look like an issue about solving community issue). Judging from you short descriptions in #2970, addition of rc-files and |
I have constructive proposal: since traversing and discovery of configs blocked by #2970, I propose at least to implement In other words, so that Yeap, we will be still forced to use |
|
@bookman25 yea, that's a good point as well; similar to how the multi-config runner may have implications on the design of the |
But it can't support JS files, which |
This will be in Jest 20, soon. |
Darn, too late. May I suggest that we start moving such files out of the project root and into a "config" or ".config" directory instead? I'm imagining a far off utopia where we've reclaimed our project root directories. :) |
This is just a default and it is optional, you can always specify |
@cpojer it's obliging to use a .json or .js extension anyway, so we can't do |
Yep, same here, getting this:
|
@cpojer No updates on this? |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
As described in the comments in #2203, this PR aims to add support for Jest config to be specified in a .jestrc file
Config now attempts this order of priority:
--config
passed in as a command-line arg (so anyone using an unexpected format, e.g. json or yml, of.jestrc
with explicit--config
should be unaffected by this update)module.exports
from the.jestrc
at the cwd.jest
at the cwdAnd then the last 2 are repeated, but one directory up, until either a non-falsy config is found, or we can't go up a directory anymore.
The reason for checking for a package.json at every directory level is to ensure that this requirement is met:
Test plan
I'll write some unit-tests once the actual business-logic here is confirmed
But I've tested locally that config-selecting functionality works as expected in the following scenarios:
--config
followed with no.jestrc
or package.json config--config
followed with.jestrc
and package.json config--config
or.jestrc
.jestrc
followed when before package.json config.jestrc
ignored, when package.json is before.jestrc
, and has config