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

Jest source maps not working #279

Open
schw4rzlicht opened this issue May 24, 2020 · 10 comments
Open

Jest source maps not working #279

schw4rzlicht opened this issue May 24, 2020 · 10 comments

Comments

@schw4rzlicht
Copy link

Hey there!

I'm pretty new to TypeScript/jest and I spent hours in figuring out why line numbering in failing tests are wrong so please bear with me.

I'm not sure if I missed something or it's an actual bug and I couldn't find anything close to my problem online. When running install(), line numbering breaks, when commenting it out, everything works fine (but of course stack traces don't work any more). It doesn't matter if install() is run in test code or in imported production code, test line numbering always breaks.

I have set up a demo repo over here.

Thanks for your help!

@LinusU
Copy link
Collaborator

LinusU commented May 25, 2020

Did it work with 0.5.18? 🤔

@schw4rzlicht
Copy link
Author

I just tested 0.5.0 and 0.5.18 and they both have the same problem.

@LinusU LinusU changed the title 0.5.19 breaks jest source maps Jest source maps not working May 26, 2020
@andinoJamesV
Copy link

andinoJamesV commented May 30, 2020

Possibly related and probably not this Libs issue istanbuljs/nyc#1323 as Jest uses Istanbul nyc.

Any suggestions?

Also this error is occurring with nyc that is strange

robot@raspberrypi:~/Sketches/JS/Classes/_/o $ ../node_modules/.bin/nyc  --require=../node_modules/source-map-support/register.js  --source-map=false --cache=false --compact=false  ../node_modules/.bin/_mocha Test/Spork.js
Cannot find module '../node_modules/source-map-support/register.js'
Require stack:
- /home/robot/Sketches/JS/Classes/_/node_modules/nyc/bin/nyc.js

Verified that register.js is where it is expected

My suspicion is mix and match CJS and ES module types are the problem?

Lib is working with just mocha though

@andinoJamesV
Copy link

So I kept digging into the project and code coverage is built into V8

@schw4rzlicht
Copy link
Author

@Heavy-Gray I'm not sure how I could actually help.

My suspicion is mix and match CJS and ES module types are the problem?

Where does that suspicion come from? Did you have a look at the sample I linked above? Do you mean b/c of

{
  "compilerOptions": {
    "esModuleInterop": true
  }
}

https://github.com/schw4rzlicht/node-sourcemap-jest-demo/blob/master/tsconfig.json

@andinoJamesV
Copy link

@schw4rzlicht No for sure you can`t I was bouncing around broken libraries and by chance this lib and thread came up.

Just to verify node-source-map-support is working and the problem you are having is in nyc or Jest

@schw4rzlicht
Copy link
Author

Just to verify node-source-map-support is working and the problem you are having is in nyc or Jest

Yes. Debugging and stack traces have the right line numbers outside of Jest tests.

schw4rzlicht pushed a commit to schw4rzlicht/twitch2ma that referenced this issue Jun 10, 2020
# [1.13.0-rc.1](v1.12.0...v1.13.0-rc.1) (2020-06-10)

### Bug Fixes

* Enable graceful shutdown ([24272bd](24272bd))
* Fix line numbers being wrong in index tests (see evanw/node-source-map-support#279) ([56fd884](56fd884))
* Graceful closing connections ([9b2ceb7](9b2ceb7))
* Improve graceful shutdown ([626430d](626430d))

### Features

* Add command to log when permissions are denied ([40bdf94](40bdf94))
* Add sACN lock ([c3a08c5](c3a08c5)), closes [#2](#2)
schw4rzlicht pushed a commit to schw4rzlicht/twitch2ma that referenced this issue Jun 15, 2020
# [1.13.0](v1.12.0...v1.13.0) (2020-06-15)

### Bug Fixes

* Add default sACN object to config ([15970fb](15970fb))
* Add more error capturing ([5b576a6](5b576a6))
* Add more help to errors ([d7c9103](d7c9103)), closes [#7](#7)
* Detect corrupt sACN ([675cbbc](675cbbc))
* Enable graceful shutdown ([24272bd](24272bd))
* Error handling for Twitch chat client ([dc0fda9](dc0fda9))
* Error reporting when config file was not found ([78fc048](78fc048))
* Exit instead of throw ([fb5576f](fb5576f))
* Filter exceptions ([7777311](7777311))
* Fix line numbers being wrong in index tests (see evanw/node-source-map-support#279) ([56fd884](56fd884))
* Graceful closing connections ([9b2ceb7](9b2ceb7))
* Improve error handling ([58c40cf](58c40cf))
* Improve graceful shutdown ([626430d](626430d))
* Integration tests ([61194d8](61194d8))
* Make sACN interface configurable ([48eafa0](48eafa0))
* Null pointer when config.sacn is not used ([08b69f2](08b69f2))
* Null pointer when sACN was never received ([bc30dd9](bc30dd9))
* Resolve path to .env ([9d97959](9d97959))
* Resolve sentry.json ([4f60c91](4f60c91))
* Throw TelnetError where it occurs ([efb525a](efb525a))
* Timing out sACN according to E1.31 specs ([ffdaf65](ffdaf65))
* Wrong function call in production ([cef76ca](cef76ca))

### Features

* Add command to log when permissions are denied ([40bdf94](40bdf94))
* Add sACN lock ([c3a08c5](c3a08c5)), closes [#2](#2)
* Add sACN status ([c14bdba](c14bdba))
* Add sentry ([95ba4fe](95ba4fe))
@dmaretskyi
Copy link

Related issue: jestjs/jest#10330

@stavalfi
Copy link

stavalfi commented Feb 5, 2021

as a workaround:

if (!process.env.TEST_MODE) {
  require('source-map-support').install()
}

until this issue is fixed.

also, https://github.com/evanw/esbuild has impact as well because of this issue. probably https://github.com/swc-project/swc also.

@silasdavis
Copy link

Are you using ts-jest? I am seeing this issue when using ts-jest and I have opened a ticket with minimal repro here: kulshekhar/ts-jest#2372

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

6 participants