Skip to content
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

Coverage Report File Extensions are wrong #67

Open
CodeMedic42 opened this issue Dec 29, 2022 · 1 comment
Open

Coverage Report File Extensions are wrong #67

CodeMedic42 opened this issue Dec 29, 2022 · 1 comment

Comments

@CodeMedic42
Copy link

I am getting a coverage report using PTI. However I am running into many issues which I am failing to find decent answers for.

I am only going to pick one issue for now.

I am getting a coverage report and can render it using nyc. It also appears to be taking the source map into account. However the resulting report is rendering files names incorrectly.

The file names are close but incorrect. The report is showing the file extension as jsx.js/tsx.js/ts.js instead of just jsx/tsx/ts.

Would anyone have any idea on what could be going on here? I am using Webpack and can provide the config for that if that might help.

Here is a snippet of the report from the console.

.nyc_output/src/components/drop-down               |   70.39 |      100 |     100 |   70.39 |                                                                                                                                                                                                                                                          
  anchor-binding.tsx.js                             |   75.79 |      100 |     100 |   75.79 | 3,13-15,17-27,38-41,69-75,78-87,102,127                                                                                                                                                                                                                  
  drop-down-context.jsx.js                          |   89.47 |      100 |     100 |   89.47 | 4-5                                                                                                                                                                                                                                                      
  drop-down-list-item.jsx.js                        |      88 |      100 |     100 |      88 | 14-16,37-44,48                                                                                                                                                                                                                                           
  drop-down-list.tsx.js                             |   62.06 |      100 |     100 |   62.06 | 11-12,14-24,35-40,79-107,110-112,116-118,130                                                                                                                                                                                                             
  drop-down.tsx.js                                  |   64.74 |      100 |     100 |   64.74 | 16-17,19-29,118-129,135-146,161-168,172-174,177,180-182,189-195,204-206,208-210,213-227,241-245,249-257,260-272,275-290,293-304,307-309,313-315,330-332,334-336,342-356,363-369,372-388,397-402,405-407,417-419,429-431,475                              
  index.ts.js                                       |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                          
  list-item-button.jsx.js                           |   77.06 |      100 |     100 |   77.06 | 14,16-19,21-30,50-55,58-60,74                                                                                                                                                                                                                            
  list-item-content.jsx.js                          |   77.27 |      100 |     100 |   77.27 | 10-11,13-22,35-37       
@CodeMedic42
Copy link
Author

I found where this issue is stemming from. In file "https://github.com/istanbuljs/puppeteer-to-istanbul/blob/master/lib/output-files.js" there is a method "rewritePath". In there on line 60 the logic in the code is expecting the file extension to be ".js".

However, I am assuming, Puppeteer utilizes the source map and the file name ends with its original extension after the coverage data is retrieved. This could obviously be anything before a transpiler is ran.

I'm not sure what the exact purpose of this method is other than remapping the path to another. But it seems to me that expecting the extension to always be ".js" is not entirely correct.

Unless some other part of the code requires ".js", I think the easiest thing would be to just remove the ".js" strings from the following lines 60, 63, 69, 72.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant