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

nyc makes stack traces unreadable #285

Closed
jantimon opened this issue Jun 25, 2016 · 10 comments
Closed

nyc makes stack traces unreadable #285

jantimon opened this issue Jun 25, 2016 · 10 comments

Comments

@jantimon
Copy link

jantimon commented Jun 25, 2016

When adding nyc to my ava test runs I receive wrong file numbers in stack traces
as shown in the following examples:

Without nyc

ava -v

returns:

TypeError: this.getModuleNameById is not a function
      mymodule/index.js:137:52

With nyc

nyc ava -v

returns:

TypeError: this.getModuleNameById is not a function
    mymodule/index.js:9:7575

(my error was neither in line 9 nor in column 7575 but in line 137)

@novemberborn
Copy link
Contributor

Yea, this is a known issue, although looking through the issue list it's not explicitly tracked.

Code coverage works by transforming the original source code. Stack traces need to be translated in order to be accurate. nyc doesn't attempt to do this. It's tricky because AVA does and it's unclear how between the two of them stack trace conversion would interact.

@jantimon
Copy link
Author

Could a sourcemap solve this?

@novemberborn
Copy link
Contributor

Yes, and I prototyped a solution in #217. I'm not entirely sure we can get source maps out of istanbul though, and I haven't had the time to research the interaction of multiple source-map-support installations within the same process.

@jantimon
Copy link
Author

I see - sounds way more complicated than I thought..

@bcoe bcoe changed the title Nyc makes stack traces unreadable nyc makes stack traces unreadable Jun 27, 2016
@bcoe
Copy link
Member

bcoe commented Jun 27, 2016

see also: #137

@bcoe
Copy link
Member

bcoe commented Jun 27, 2016

CC: @gotwarlost it would be nice to consolidate Istanbul and nyc's source-map handling, and to address issues such as stack traces 💯

@kpdecker
Copy link
Member

(Deleted prior comment)
It appears that this was throwing and causing the non-instrumented path to trigger, which then defaulted to the original source map, vs. the new one. Continuing investigation.

@lxe
Copy link

lxe commented Sep 15, 2016

If you already use babel, one way to allow error stack traces to work with node-sourcemap-support is to use https://github.com/istanbuljs/babel-plugin-istanbul, and set nyc's "sourceMap" and "instrument" settings to false.

@sompylasar
Copy link

#619 (comment)

@bcoe
Copy link
Member

bcoe commented Oct 4, 2017

closing in favor of #619.

@bcoe bcoe closed this as completed Oct 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants