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

No test output when debugging #423

Closed
4 tasks done
seaders opened this issue Jun 28, 2024 · 7 comments · Fixed by #425
Closed
4 tasks done

No test output when debugging #423

seaders opened this issue Jun 28, 2024 · 7 comments · Fixed by #425
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@seaders
Copy link

seaders commented Jun 28, 2024

Describe the bug

I don't get any output stdout/stderr in the Test Output, and only the initial start line in Debug Console.

This issue is exactly the same as described for #137 and #117 which seems to have been fixed in #228, but there's no evidence for output from a debug session / debugging an invidual test.

Reproduction

  1. Using the vitest extension, choose to debug any test file, or any indvidual test that has console.log or console.error
  2. Test Output records nothing, and Debug Console only,

/Users/seaders/.nvm/versions/node/v20.11.1/bin/node ./../../../../seaders/.vscode-insiders/extensions/vitest.explorer-0.12.3/dist/debug.js

vitestdebugoutput.mp4

Output

<empty>

Version

0.12.3

Validations

@seaders
Copy link
Author

seaders commented Jun 28, 2024

This can be overcome with a setting like below, but I'd still consider this a bug, or at the very least extremely obscure and something that needs better documentation somewhere.

import { defineConfig } from "vitest/config"

export default defineConfig(() => {
  return {
    test: {
      disableConsoleIntercept: !!process.env.VSCODE_INSPECTOR_OPTIONS
    }
  }
})

@sheremet-va sheremet-va added p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Jun 29, 2024
@sheremet-va
Copy link
Member

sheremet-va commented Jun 29, 2024

There is a bigger problem. The "last" debug run is not reordered by VS Code at all (you can see in your Test Results the last debug run is not in a finished state). I don't know why it is so. When you start another run, the previously empty run becomes populated for some reason.

@sheremet-va
Copy link
Member

This should be fixed in 0.12.4.

@seaders
Copy link
Author

seaders commented Jul 1, 2024

I'd contend that that fix is just as bad, because the console output doesn't come until the end of the test. Consider a regular debugging session like the one in the video, and this,

image

When you're in a breakpoint after some print statements, you want to be able to see those print statements. Personally, I'd prefer the behaviour that occurs when you set disableConsoleIntercept,

image

Because then you see all the output prior to that point when in a breakpoint.

@sheremet-va
Copy link
Member

Then it's a good thing that disableConsoleIntercept exists, isn't it 😄

Use it if you prefer it that way. There is nothing that can be done in the extension because the console is intercepted by Vitest and the breakpoint makes it impossible to send the data in time.

@seaders
Copy link
Author

seaders commented Jul 1, 2024

I get that, I really do. Any chance of updates to docs? Or, if you point me to where to update, I'd be happy to contribute to a few sentences.

Overall, I felt there's a lack of ... love/tlc to this specifically IMO fantastic feature of vitest with VS Code. I found that most of the docs focus on testing the "whole" unit of a project, the way that you'd run vitest cli, rather than this kind of situation, using testing during development, writing code, test, debug, tinker, test and debug again. The docs barely even make mention of context menu "Debug Test", which I find an incredibly useful and powerful tool, but then got incredibly frustrated with the situation I then found myself in with no output.

I then only found reference to disableConsoleIntercept deep in a closed github issue, or SO thread. I can't even find where I found it in my history.

@sheremet-va
Copy link
Member

Looks like disableConsoleIntercept is not documented in Vitest docs. You can open a PR there.

I found that most of the docs focus on testing the "whole" unit of a project, the way that you'd run vitest cli

I do not have a lot of time working on every feature in parallel to also write comprehensive documentation for everything. There is however an open issue to add more documentation: #338 (inspired by jest extension readme: https://marketplace.visualstudio.com/items?itemName=Orta.vscode-jest)

Feel free to open a PR with instructions on how to properly run those types of tests.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants