-
-
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
Jest 22 Coverage Fail on TS files #5428
Comments
Would a |
Don't think it would solve whole problem. If you are talking about npm realpath - if I pass c:/abc it spits out c:/abc. If I pass C:/abc, I get C:/abc. It does not seem to normalize drive letter case. Realpath is cool but need to match drive letter as well. I would maybe even do it manually since it looks like corner case for given Jest/Istanbul scenario. |
Not the native |
`fs.realpathSync( 'C:\' ) fs.realpathSync( 'c:\' ) Many default normalization functions ignore case letter because normally it should not matter whether drive letter is upper or lower case. Therefor maybe Jest could have custom normalization function which would combine something like realpath with something like this:
Basically goal is to make sure that all paths arriving from Jest to "Istanbul-lib-coverage" module would be standardized. Same path = same string. One note though - I would only mess around with drive letter using above custom code - not the whole path. This is because on Linux paths are case-sensitive and I would not want someone to start using random-case paths on Windows and find them working only to fail when trying to launch on Linux. PS.: maybe it is time for Istambul to update as well :/ Although I still believe Jest should normalize paths regardless. |
I ran into the same issue, but it was caused by doing an import using two different cases. Notice the t vs T
vs
This caused tsc to generate both files in the output. |
@WhiteTurbine see using native |
Turns out process.binding('fs').realpath works differently from require( 'fs' ).realpath. Did not know that. This should help if added to Jest. I regards to import paths - good point and might help others. However, in my case drive letter differs. I do not have drive letter in my imports - must be something else. However, even in import situation desvribed by @jamesrusso - shouldn't Jest work well even if cases are mixed? Thing is - in Windows paths are not case sensitive. |
This issue was closed because it has been stalled for 7 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Please re-open - bug still exists:
#5109
Issue remains in the newest version of Jest at a time (22.1.4). Last working version I found was 21.2.1. This issue can be reproduced only on Windows.
Jest is registering same file to Istanbul-lib-coverage twice with path that only differs in case (“c:/” vs “C:/”). This makes Istambul add file twice using “addFileCoverage” method. As a result coverage report shows 2 files instead of 1. In addition to showing 2 files, it is not able to find one of the paths in its internal array of coverage information (this.data) using “fileCoverageFor” method because file addresses there are case sensitive.
I have worked-around the issue by overriding “istanbul-lib-coverage” slightly using “override-require” node module. However, proper fix should probably be in Jest and this requires further investigation.
The text was updated successfully, but these errors were encountered: