-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Debugger in vs-code does not stop at breakpoint but elsewhere #5380
Comments
Can you test if This issue has come up before - it's not really Vitest related. I would guess that your breakpoints don't work even when debugging in browser during development. Related discussions: |
This is most often related to bad or missing sourcemaps |
No, it has the same bug.
Breakpoints work well in browser. Breakpoints work well starting vite dev server in "Javascript debug terminal". So it's pretty much narrowed down to vitest I'd say.
^ This is not related to breakpoints
^ this is describing exactly the same problem. Source maps are turned on as you can see in my minimalistic example: https://github.com/bonham/vitest-debug-issue-js/blob/main/vite.config.js |
Breakpoints seem to work fine when using Chrome Dev tools: vitest-5380.mov |
Hi @AriPerkkio, yes you are right. I tried the same and also for me breakpoint works well. This is a good workaround. Summary:
Idk, but seems not a vitest issue but maybe a vs-code issue ( vue plugin or whatever .... ) |
Not sure if this is helpful or not, but I can reproduce this issue (in the VS Code debugger) without vue at all, just a plain node app. Disabling coverage when a debugger is attached is a workaround but unfortunate. |
with vitest or even without vitest? |
@bonham Oh sorry, yes with vitest. |
I just tested debugging in VS Code with a node app instrumented with istanbul and esbuild and it works fine with breakpoints being where they should be. So I think there's something in vitest specifically that is causing the problem, I don't think that VS Code is the root problem (although maybe a contributing factor). |
@CreativeTechGuy how can I reproduce this issue? Is it with |
@AriPerkkio Sorry for the delay, this is gnarly. I couldn't reproduce it starting from an empty repo, but I started deconstructing my massive repo and I was able to get it down to a few dozen lines total across all files. I've put a ton of information and very detailed steps in the repo README. Let me know if you are able to reproduce. I've been able to reproduce it across two computers (Windows 10 & 11) so far so hopefully you can too. https://github.com/CreativeTechGuy/vitest-coverage-debugger-issue-repro |
We are experiencing this same problem at the moment and for us the workaround going through the Chrome Devtools is also working, but a lot less convenient to use. |
Describe the bug
In vanilla project with vue3 + vitest + @testing-library/vue + node 18.18.2 or 20.11.1, setting and debugging breakpoints in vs-code on windows 11 does not work as expected. Debugger stops at wrong location. I am using vue single file components ( aka .vue files )
Seems to be transpiling and/or sourcemap issue.
The issue disappears when removing <style>...</style> section in .vue file
Reproduction
Result: Debugger stops at wrong line
Expected: Debugger should stop at correct line
Issue goes away when removing <style>...</style> section in .vue file
Example file
SimpleComponent.vue
Example
simple.spec.js
Full example vanilla project to clone and reproduce: https://github.com/bonham/vitest-debug-issue-js
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: