-
-
Notifications
You must be signed in to change notification settings - Fork 538
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
Source Maps with mocha and ts-node and nyc #898
Comments
What is wrong about the mapping? It looks to me like an entirely different error is being thrown, because the error message is totally different. When I look at where that error is being thrown in the source code in github, it looks like the sourcemap is referring to the correct line number. |
@cspotcode what error did you get? and did you go to the mentioned commit? and added the 'test' error? |
@hasezoey I checked out the code, made the modification to add Then I ran mocha in my terminal:
It looks correct. The error message is correct, and the line number is correct. |
@cspotcode so i tests again (i didnt test again since the post of this issue), but this time with the latest commit (made some since the post of this issue) and upgraded from mocha 6.2.2 to 7.0.0 and ts-node to 8.6.2, and because of the changed code since then i placed the error this time on
PS: i dont have mocha installed globally, but i have ts-node installed globally but on the same version (8.6.2) like the project Update: the current commit is |
@hasezoey I created a reproduction here: It's running on Github Actions so we can both see the same logs. Open the link above, expand the "Run" node, and scroll to the bottom. Is that what you're seeing? EDIT feel free to fork my reproduction and tweak it. If you open a PR against https://github.com/cspotcode/ts-node-repros it should run Github Actions. |
ok i tried running PS: i will update the issue to the current findings |
@hasezoey I don't know how much help I can be. If someone can prove this is a |
@cspotcode thanks for you time, i found an issue that is exactly the problem: istanbuljs/nyc#619 |
@hasezoey Thanks for sharing the link, I learned a few things reading it. Looks like nyc + mocha + ts-node requires a handful of flags:
Also, they're saying source-map-support needs to be told to hook into Where we install source-map-support: Also, nyc has their own library for hooking require(). https://github.com/istanbuljs/istanbuljs/blob/master/packages/istanbul-lib-hook/index.js |
@cspotcode i already tried these options, but they didnt help (for nyc) so i just made a local script and an ci script to have accurate source map lines while testing locally |
i didnt know a better title
The Issue
i noticed strange source mappings when there is an error outside of the test file of mocha (like the actual source files that the tests are for) where
happen, but actually should be
Using & Versions
Already Tested
source-map-support/register
in every file, just in mocha, in the package root file and in the file the example error is - with no resultReproduction
Example project: https://github.com/typegoose/typegoose (current commit
ba77676c0b1f71e80bbcf58987a27576bb5164c9
)npm run test
for the tests - which should just run finesrc/prop.ts
at line 276new Error("test");
- as an example error-> i dont know if im going something wrong, but i noticed it in some other private projects too
Notes
tsconfig.json
is used for tests & vscode intellisense andtsconfig.build.json
is used for shippingPS: if an error happens in an test file (in the example project: any file in
test/
) has the right mappingsUpdate
as found in this comment it is actually involving nyc, without it, it reports fine
The text was updated successfully, but these errors were encountered: