fix: show console logs in "Test Output" #228
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently this extension uses
TestRun.appendOutput
only to surface Vitest server logging:vscode/src/runHandler.ts
Lines 309 to 314 in d8c8908
This approach might work in some cases, but it seems inconsistent (for example, when running multiple tests at once).
I think the better way to surface logs for each test run is to use either:
Task.logs: UserConsoleLog[]
orReporter.onUserConsoleLog: (log: UserConsoleLog) => Awaitable<void>
Ideally, we probably want to go with the 2nd approach
onUserConsoleLog
where we match Vitest'slog.taskId
against Vscode'sTestRun
to call specificTestRun.appendOutput
in real time. But for this, it requires some more refactoring around vscode/vitest task matching utility, so for now I went with 1st approach whereTask.logs
are reliably available after the test is finished.todo
Show demo
2024-02-16.12-11-59.webm