-
Notifications
You must be signed in to change notification settings - Fork 157
Improve .babelrc lookup #93
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
Conversation
Now searches with a depth of infinity from the file path, as described in vuejs#66.
The issue is that the test is being run in |
Thanks for the PR. What's your use case? |
The ability to run jest from anywhere in the npm project, particularly the location of the spec file. In particular this allows IntelliJ's Jest plugin to run without configuration in the IDE (by default IntelliJ sets the working directory to the path of the spec file when running tests from the editor) It is also consistent with babel-jest. |
We should keep the same functionality as babel-jest, but I don't think babel-jest searches in parent directories for the babel config file. I'll have to take a deeper look at the source code. From what I could tell the babel options are found when the transformer is initially created, which I think is in the project root. We could implement something similar. |
My understanding is that this loop removes the last part of the path until it hits the root or escapes due to cache or finding the config. I have made an assumption about the filename being passed in, I could test that later if you like. https://github.com/facebook/jest/blob/4a46993b5116838a55666ac8c0522a71457eb7c5/packages/babel-jest/src/index.js#L37 |
You're right, it does. Ok, how about we rename the root babelrc as part of the test script, so it doesn't find it when the tests are running, then rename when the process exits? |
My feeling is that it is better to mock our findBabelConfig dependency so we aren't escaping the test sandbox, and the unit tests are more contained. I'm quite open to your feedback though |
For tests that depend on there being no babelrc, rename the package one now that we recurse.
I made the test changes as you suggested. |
Hey, sorry that I've been silent on this. It slipped my radar. I agree that we should add this feature, but we need a test for the filepath functionality specifically. Are you able to add a test to check that the babelrc searching uses the current directory? |
Sure, no problem. Likely tomorrow. |
Tests that babel is read from cwd, and not the project root.
@eddyerburgh Are those the tests you wanted? |
Thanks for adding the tests. I was thinking they should be tests that call through the whole |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks :)
Now searches with a depth of infinity from the file path, as described
in #66.
For my personal use, just switching the depth from 0 to the default (INFINITY) was enough; but as per the ticket I try to use the filePath now as well.