-
-
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
fix: absolute paths in moduleDirectories
are invalid in Windows OS
#5398
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
Codecov Report
@@ Coverage Diff @@
## master #5398 +/- ##
==========================================
+ Coverage 62.24% 62.24% +<.01%
==========================================
Files 205 205
Lines 6931 6932 +1
Branches 3 3
==========================================
+ Hits 4314 4315 +1
Misses 2616 2616
Partials 1 1
Continue to review full report at Codecov.
|
CLA (Contributor License Agreement) has now been signed. |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
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.
Can you include a test for this? Also, please update the changelog.
Don't worry about multiple commits, btw. We squash on merge 🙂
}); | ||
|
||
it('can resolve node modules relative to absolute paths in "moduleDirectories"', () => { | ||
const cwd = 'D:\\project'; |
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.
this won't pass on a mac or linux. Can you switch on os.platform === 'win32'
and use unix style paths? We run CI on appveyor, so it should still guard against regression
@SimenB ..mind if I ask you a quick question? As you saw in the first iteration of the unit tests, I wanted to test how I actually didn't notice your comment until after I'd iterated and written a 2nd version. Your suggestion to use a switch statement to run one test that's dependent on the platform of the machine executing the test runner is one way to go. But it does leave a lot of things untested. The idea I had was to mock the global The methodology is simple and sound. The problem that I find myself needing to work around.. is that the Is there any way to chain two tests together.. programmatically.. in code? If not, should I combine the two tests into a single Any ideas? |
I'd use a combination of An alternative is to write an integration testing your change on a higher level, instead of the actual paths being used. Not sure if that's viable here, though. |
if I was to call and if somehow that was possible.. what would the behavior be within those other modules when multiple tests running in parallel each attempt to mock this same library? |
more concretely:
so.. |
Would it be terrible of me if I just combine the 2 tests into a single function.. so they can run as one sequential block? |
quick status update.. branch dedicated to debugging the problem
observation:
|
PS: sorry that there's a commit that's floating toward the end of this thread. I pushed it from a virtual machine that had its clock set without a timezone. My bad. |
|
2nd iteration of passing unit tests
observation:
|
feels done to me.. |
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!
Sorry it took so long writing the tests for it 🙁
@warren-bank I've pushed an update to the illustrating how to use I'm sorry I wasn't clearer in my original comment, and that it meant you spent some time needlessly fighting the
Thank you so much for the fix though, looks really clean. |
no worries.. I'm glad to contribute and if I can learn something new in the process, then all the better. I'm interested to see how you did it. |
that's very interesting.. so you..
observation:
question:
question:
question:
|
sorry.. I really need to stop asking dumb questions.. and just RTFM! I hate it when people do that :) |
It needs to happen before we re-
No magic happening - it's not cleaned up. We could add a
No worries! |
ohhh.. now it's all making sense.. so I still need to read the manual.. but yeah.. that's making sense to me. Thanks! |
would it be fair to assume that the way jest is creating a mock: would look something like: |
Conceptually, yeah. Jest implements |
cool... thanks again for the lesson. ok.. I'm calling it a night :) |
Pushed the additional cleanup |
@warren-bank mind rebasing? |
not at all.. |
oops.. I don't have much (any) experience using pull requests on github.. git clone "https://github.com/warren-bank/jest.git"
cd jest
git checkout -b "issue-5396"
git push -u origin "issue-5396"
git checkout master
git reset --hard "c243f67efbae70bd416a61b0c899485bde3a702b"
git remote add facebook https://github.com/facebook/jest.git
git pull --ff-only facebook master
git push -f origin master
git checkout -b "issue-5396-final"
# merge HEAD of "issue-5396" into "master"
git add --all .
git commit -m 'fix #5396: preserve absolute paths in `moduleDirectories`'
git push -u origin "issue-5396-final"
git checkout master
git merge "issue-5396-final"
git push -u origin master I'll make a new pull request.. |
oh.. re-opening it works too |
hope you don't mind.. Figured I'd leave the higher scope just waiting to see if all the validation checks pass.. |
made another change.. |
cool.. |
hmm.. that's weird my final commit was a minor tweak to the CHANGELOG.. is there a way for you to manually re-run the suite? update: i pushed an amended commit.. it worked.. the tests are running now.. update: all good.. |
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. |
closes: Issue #5396