istanbul icon indicating copy to clipboard operation
istanbul copied to clipboard

_

Open ghost opened this issue 7 years ago • 20 comments

_

ghost avatar Jun 12 '17 18:06 ghost

I have the same problem, my repo is: https://github.com/FezVrasta/popper.js/pull/314

To reproduce just run yarn test

FezVrasta avatar Jun 19 '17 09:06 FezVrasta

I have the same issue. I did a bit of investigation and it seems to be at this point: https://github.com/gotwarlost/istanbul/blob/master/lib/report/html.js#L288

At the point it errors on my project, structuredText is an array of 60 objects but startLine is 64, so it's returning undefined.

However the coverage report is generating correctly!

I put in a local hack to stop the error from showing: ... && (startLine <= structuredText.length) on the following lines: https://github.com/gotwarlost/istanbul/blob/master/lib/report/html.js#L205 https://github.com/gotwarlost/istanbul/blob/master/lib/report/html.js#L236 https://github.com/gotwarlost/istanbul/blob/master/lib/report/html.js#L283

Not sure what's causing this issue though as I'm not too familiar with the Istanbul source, so would be good to get some suggestions on a fix to the underlying problem?

FYI: This issue started appearing when I updated our project to angular v4.x and angular-cli v1.1.2 with karma-coverage-istanbul-reporter v1.3.0

brian-griffin avatar Jun 21 '17 14:06 brian-griffin

it is solved with: https://github.com/gotwarlost/istanbul/pull/819

cenkingunlugu avatar Jun 22 '17 10:06 cenkingunlugu

Hello. When it's going to be fixed? I cannot get proper html report

arsenslyusarchuk avatar Nov 15 '17 16:11 arsenslyusarchuk

No news ?

QLaille avatar Dec 01 '17 16:12 QLaille

Dev's on holiday? How long is this going to take?

vviikk avatar Dec 14 '17 01:12 vviikk

Reverting istanbul to 0.4.4 worked for me.

joshuabyler avatar Jan 03 '18 16:01 joshuabyler

I am using gulp-istanbul 1.1.3 which depends on istanbul 0.4.x and I encountered this issue (when it was using istanbul 0.4.5). Manually forcing gulp-istanbul to use istanbul 0.4.4 resulted in the same error.

@heronblade Is it possible another change helped you fix this or was it just the downgrade?

Also, this issue seems to be stuck without any updates or progress. Is there anything users can provide to help the project maintainers root cause this? It seems related to source maps but my mocha test setup doesn't really do anything with source maps so I'm not sure where to try to fiddle with things to get around this error.

vegetabill avatar Feb 08 '18 23:02 vegetabill

Reverting to istanbul 0.4.4 did not solve the issue for me, either.

binomialstew avatar Feb 13 '18 18:02 binomialstew

Bump. So this issue is an unsolved blocker? Any other workaround suggestions. Istanbul seems like the only game in time for modern js coverage so I'm a bit lost where to go from here.

vegetabill avatar Feb 19 '18 19:02 vegetabill

FWIW, I gave up using gulp to drive my mocha test run. When I instead invoked nyc via an npm script, it worked fine. I think that means using this package by itself is no longer supported.

vegetabill avatar Mar 07 '18 23:03 vegetabill

Check out https://github.com/gotwarlost/istanbul/issues/602 for a resolution

toddpi314 avatar Apr 06 '18 14:04 toddpi314

I am using simple istanbul and still recieveing this error. Does anyone know how to solve it? It is generating lcov.info correctly but not index.html

anki06 avatar Aug 03 '18 05:08 anki06

FWIW I switched to using nyc via its CLI and it's working. I think this means this package is unmaintained/dead for other use cases.

vegetabill avatar Aug 03 '18 21:08 vegetabill

In my case, i am using protractor + istanbul to get coverage for integration testing. So need to pre-instrument source file before test and get this error in istanbule report. I find if i use origin source file to replace the instrumented source file, then it works.

Checking code, structuredText[startLine].text is undefined due to the instrumented source file text structure is changed and the [startLine] line is invalid.

minimorph223 avatar Sep 13 '18 21:09 minimorph223

I've started seeing this issue a couple days ago. A week ago everything worked smoothly. Looks like our js source code was changed and somehow uncovered this bug.

    "istanbul": "^0.4.5",
    "istanbul-combine": "^0.3.0"

We are combining coverage from a set of files. Looks like calculation is fine, but the report generation is failed

=============================== Coverage summary ===============================
Statements   : 29.37% ( 1614/5496 )
Branches     : 9.96% ( 442/4436 )
Functions    : 28.57% ( 932/3262 )
Lines        : 30.26% ( 1276/4217 )
================================================================================
node_modules/istanbul-combine/node_modules/istanbul/lib/report/html.js:283
                    text = structuredText[startLine].text;

Another possible reason can be that we switched from angulajs-1.7.0 to angularjs-1.7.3 a month ago


fixed: the issue was that our source code and coverage information was not synchronized, we are using karma/istanbul/jasmine for e2e tests coverage calculation

VladyslavKurmaz avatar Nov 15 '18 09:11 VladyslavKurmaz

Fixed: I remove karma-coverage and used karma-coverage-istanbul-reporter

SasanFarrokh avatar Apr 18 '19 19:04 SasanFarrokh

For rollup-plugin-istanbul users, the babel plugin has to come after istanbul plugin. https://github.com/artberri/rollup-plugin-istanbul#other-usage-options

luwes avatar May 19 '19 16:05 luwes

Hi , I am also facing this issue and this https://github.com/gotwarlost/istanbul/pull/819

Solved it for me . Please can this issue be resolved so that we don't have to patch Istanbul ourselves.

kushmisra avatar Dec 05 '19 18:12 kushmisra

The real problem seems not to be in "html" reporter module.

I ran into the same problem and after some investigations, I make a patch myself on the "html" reporter module to skip the error and I realize that the highlighted uncovered lines seems to be shifted with the real code. The reason was that in my bundler (webpack) I set another loader ("imports-loader") before the "babel" one which brings instrumentation in my configuration. So "babel" took an already transformed code before to send it to "istanbul", and all offsets were shifted and wrong. I ordered my bundler loaders to pass by "babel" loader first and all is good now 🙂

Hope this trick can help another desperate code coverage lover, and sorry for my bad english

flaval avatar Jan 13 '21 01:01 flaval