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

console.log buffering while debugging is confusing #537

Open
4 tasks done
btj opened this issue Nov 19, 2024 · 1 comment
Open
4 tasks done

console.log buffering while debugging is confusing #537

btj opened this issue Nov 19, 2024 · 1 comment

Comments

@btj
Copy link

btj commented Nov 19, 2024

Describe the bug

While debugging a Vitest test case using the VSCode plugin's "Debug Test" functionality, output generated by the test case using console.log does not show up in the Test results pane immediately when the console.log call is performed; it only shows up at some later time. This is very confusing and hinders debugging.

Reproduction

The repro is here. To reproduce, put a breakpoint on the console.log line in index.test.mjs. Then choose Debug Test in the Testing view. Then choose Step Over. Notice no output appears in the Test results pane.

Output

[INFO 13:38:16] [v1.6.9] Vitest extension is activated because Vitest is installed or there is a Vite/Vitest config file in the workspace.
[INFO 13:38:19] [API] Running Vitest v2.1.5 (vitest-repro/vitest.config.js) with [email protected]: /Users/bartj/.nvm/versions/node/v22.9.0/bin/node 
[INFO 13:38:21] [API] Vitest v2.1.5 (vitest-repro/vitest.config.js) child process 36769 created
[INFO 13:38:21] [VSCODE] Watching vitest-repro with pattern **/*
[INFO 13:38:21] [API] Collecting tests: index.test.mjs
[13:38:21] Not starting the runner because tests are being collected for index.test.mjs
[13:38:22] [VSCODE] File deleted: vitest.config.js.timestamp-1732019901325-e73096b854411.mjs
[13:38:24] There is no test run for "index.test.mjs"
[13:38:24] No test run to finish for index.test.mjs
[13:38:25] [VSCODE] Ignoring file: node_modules/.vite/vitest/results.json
[INFO 13:38:30] [DEBUG] Starting debugging session /Users/bartj/.nvm/versions/node/v22.9.0/bin/node
[INFO 13:38:31] [DEBUG] Debugging started
[13:38:32] Initiating deferred test run
[INFO 13:38:32] Running 1 file(s) with name pattern: ^\s?Test Suite hello world!$
[13:38:32] The runner is starting because tests index.test.mjs were started due to a file change
[13:38:32] Enqueuing "hello world!"
[13:38:32] [VSCODE] File deleted: vitest.config.js.timestamp-1732019912764-b342c42c65b0d.mjs
[13:38:33] No task result for "index.test.mjs", ignoring
[13:38:33] No task result for "Test Suite", ignoring
[13:38:33] Enqueuing "hello world!" because it was just collected
[13:38:47] No errors found for "index.test.mjs"
[13:38:47] No errors found for "Test Suite"
[13:38:47] Marking "hello world!" as passed
[13:38:47] Ending test run index.test.mjs
[13:38:48] [VSCODE] Ignoring file: node_modules/.vite/vitest/results.json
[13:38:48] [API] Vitest WebSocket connection closed, cannot call RPC anymore.
[13:38:48] Disposing test runner
[13:38:48] Ending test run <none>

Version

1.6.10

Validations

@btj
Copy link
Author

btj commented Nov 19, 2024

I found a workaround: add disableConsoleIntercept: true to the test object in vitest.config.js; then console.log output appears in the Debug console immediately.

export default defineConfig({
  test: {
    environment: 'node',
    disableConsoleIntercept: true,
  },
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant