You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Where can I find the call stack of an exception/assert? #37
This would be a nice addition for extensions that use the Testing API generally - I think the vitest extension would benefit from the same - so I wonder whether this would be a tweak to the Testing API.
I've never written any production-ready code, so this is just a proof of concept and will most likely have issues.
To use it, clone, run npm install, then npm run package, then in VS Code Extensions: Install from VSIX....
I won't be working on a PR to get this in, partly because I wouldn't know how to test it, but mostly because I suspect @connor4312 won't want this PRing in. It doesn't seem to quite align with what the Diagnostics Panel in the VS Code Testing API is designed for - but I would welcome a tweak to this API that accommodates for this.
It would also be very cool if we could get formatted text in this panel, so that we can (for example) have the messages in different text to the stack traces - but I think that's also a Testing API concern not one for this library.
Worth noting - you can also see stack trace info by hovering over the red text to the right of the test title:
Unfortunately I just tried it, but couldn't see any noticeable difference. Even tried clocking the version number to 1.5.2 rebuilding and reinstalling. Checked I had the correct branch and your changes (buildStackPhrase was there). Same thing.
Then I loaded the project in VS Code and ran it, put a throw statement in one of the included tests and still nothing.
Not sure what you mean the assert has no call stack. When I run the same test from command line I get more complete error information including the file/line number location of the exception:
I edited my message to remove that comment as it was incorrect :)
Not sure what to suggest I'm afraid - I made the modifications on a Linux PC and installed without issue on a Windows PC today, so I'm not sure what the cause could be. I'd maybe try clearing the relevant directories from the extensions folder (~/.vscode/ on Linux) and installing again.
OK, not sure went wrong yesterday but I completely uninstalled, deleted the old extension from the extension directory and reinstalled the VSIX and it's working much better today.
This is a great improvement, but there two small issues:
1. Only getting call stacks for exceptions, not asserts
It looks like the call stack/location has been captured (see far right of red error message shows "(file://....)" but I can't see the full error message with stack, just the assert diff.
I just noticed I can hover and get the fulll stack trace:
Even better would if I could click those file locations and jump to the location of the error.
2. Clicking a file:// link in the call stack doesn't work
For exceptions (not asserts) the full stack trace is shown in the error panel however clicking a link doesn't work:
eg:
but when I click the link it shows:
I'm guessing this is related to the :linenumber:pos suffix and could be a Windows or VS code issue, but thought I'd report it anyway. Maybe there's some way to reformat the link so VS Code understands it better?
Activity
drk-mtr commentedon May 5, 2024
This would be a nice addition for extensions that use the Testing API generally - I think the
vitestextension would benefit from the same - so I wonder whether this would be a tweak to the Testing API.drk-mtr commentedon May 6, 2024
I threw together a basic example of this here:
https://github.com/drk-mtr/nodejs-testing/pull/1/files
I've never written any production-ready code, so this is just a proof of concept and will most likely have issues.
To use it, clone, run
npm install, thennpm run package, then in VS CodeExtensions: Install from VSIX....I won't be working on a PR to get this in, partly because I wouldn't know how to test it, but mostly because I suspect @connor4312 won't want this PRing in. It doesn't seem to quite align with what the Diagnostics Panel in the VS Code Testing API is designed for - but I would welcome a tweak to this API that accommodates for this.
It would also be very cool if we could get formatted text in this panel, so that we can (for example) have the messages in different text to the stack traces - but I think that's also a Testing API concern not one for this library.
Worth noting - you can also see stack trace info by hovering over the red text to the right of the test title:
toptensoftware commentedon May 7, 2024
Thanks so much for looking into this.
Unfortunately I just tried it, but couldn't see any noticeable difference. Even tried clocking the version number to 1.5.2 rebuilding and reinstalling. Checked I had the correct branch and your changes (
buildStackPhrasewas there). Same thing.Then I loaded the project in VS Code and ran it, put a throw statement in one of the included tests and still nothing.
What might I be missing?
drk-mtr commentedon May 7, 2024
Did you uninstall the real "node:test runner" extension first? I get this:
toptensoftware commentedon May 7, 2024
Yes, I uninstalled the extension first.
Not sure what you mean the assert has no call stack. When I run the same test from command line I get more complete error information including the file/line number location of the exception:
drk-mtr commentedon May 7, 2024
I edited my message to remove that comment as it was incorrect :)
Not sure what to suggest I'm afraid - I made the modifications on a Linux PC and installed without issue on a Windows PC today, so I'm not sure what the cause could be. I'd maybe try clearing the relevant directories from the extensions folder (
~/.vscode/on Linux) and installing again.toptensoftware commentedon May 8, 2024
OK, not sure went wrong yesterday but I completely uninstalled, deleted the old extension from the extension directory and reinstalled the VSIX and it's working much better today.
This is a great improvement, but there two small issues:
1. Only getting call stacks for exceptions, not asserts
It looks like the call stack/location has been captured (see far right of red error message shows "(file://....)" but I can't see the full error message with stack, just the assert diff.I just noticed I can hover and get the fulll stack trace:
Even better would if I could click those file locations and jump to the location of the error.
2. Clicking a file:// link in the call stack doesn't work
For exceptions (not asserts) the full stack trace is shown in the error panel however clicking a link doesn't work:
eg:
but when I click the link it shows:
I'm guessing this is related to the :linenumber:pos suffix and could be a Windows or VS code issue, but thought I'd report it anyway. Maybe there's some way to reformat the link so VS Code understands it better?
connor4312 commentedon Jun 6, 2024
I want to just implement better call stack support in VS Code, tracked here 👉 microsoft/vscode#214488
connor4312 commentedon Sep 5, 2024
Shipped this in VS Code, will adopt it here this weekend.
toptensoftware commentedon Sep 24, 2024
Thanks for your work on this. I haven't had a chance to test this myself yet, but appreciate the effort.