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

_ #817

Open
ghost opened this issue Jun 12, 2017 · 20 comments
Open

_ #817

ghost opened this issue Jun 12, 2017 · 20 comments

Comments

@ghost
Copy link

ghost commented Jun 12, 2017

_

@FezVrasta
Copy link

I have the same problem, my repo is:
floating-ui/floating-ui#314

To reproduce just run yarn test

@brian-griffin
Copy link

brian-griffin commented Jun 21, 2017

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

@cenkingunlugu
Copy link

it is solved with: #819

@arsenslyusarchuk
Copy link

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

@QLaille
Copy link

QLaille commented Dec 1, 2017

No news ?

@vviikk
Copy link

vviikk commented Dec 14, 2017

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

@joshuabyler
Copy link

Reverting istanbul to 0.4.4 worked for me.

@vegetabill
Copy link

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.

@binomialstew
Copy link

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

@vegetabill
Copy link

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
Copy link

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.

@toddpi314
Copy link

Check out #602 for a resolution

@anki06
Copy link

anki06 commented Aug 3, 2018

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

@vegetabill
Copy link

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.

@minimorph223
Copy link

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.

@VladyslavKurmaz
Copy link

VladyslavKurmaz commented Nov 15, 2018

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

@SasanFarrokh
Copy link

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

@luwes
Copy link

luwes commented May 19, 2019

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

@kushmisra
Copy link

Hi ,
I am also facing this issue and this #819

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

@flaval
Copy link

flaval commented Jan 13, 2021

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

@ghost ghost changed the title TypeError: Cannot read property 'text' of undefined _ Aug 15, 2022
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