added unit tests for package-hoister #2736
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Add a series of unit tests for
PackageHoister
.Previously there was only 1 unit test (not including integration tests).
With this PR, there are now enough unit testa to bump coverage of the
package-hoister.js
file to ~93% (correction, after I rebased from current master it dropped to ~88%. I guess more code was added recently). I really wanted to get as close to 100% coverage as possible, but I've been starting at this one file for a couple days and not sure what scenarios would hit some branches in the code.The real motivation was to understand how PackageHoister works in hopes of trying to look more into issue #2673 and I figured, how better to figure out how it works than to write tests for it!
Test plan
Additional notes
if you run all the tests, there seems to be 2 Flow warnings and 3 test errors. These happened after I merged in the current master code and I believe they are errors in current
master
, not my added test code.I made a custom jasmine matcher in the test file to clean up the tests. Jest has its own way of doing that, but Yarn seems to be on an older version of Jest, so I had to add it right to Jasmine. Flow was not happy with this new matcher, so I added it to the main type definition for Jasmine in
yarn/flow-typed/npm/jest-v14.0.x.js
even though that function only exists in__tests__/package-hoister.js
but I had no idea how to tell Flow to allow that method only in that one file. If someone has a better idea, please let me know!