vitest-dev / vitest-dev/vitest

console.log from webworker, when using browser runner, does not get captured

Open
#7,439 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feat: browser p2-nice-to-have
Dominant language
TypeScript
Stars
17.1k
Forks
2k
Avg merge
1d 22h
Merged PRs (30d)
94

Description

Describe the bug

When using the browser runner, if a test starts a webworker, and that worker calls console.log, the log messages are not shown as stdout like log messages from the main thread.

The only way I've found to see the log messages is to run in non-headless mode and open the JavaScript console.

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-oszejgfz?file=test%2Fbasic.test.ts

System Info
N/A

See stackblitz reproduction.
Used Package Manager

npm

Validations

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the StackBlitz reproduction and test/basic.test.ts, then trace how the browser runner captures stdout from the main thread and a started webworker. Done means console.log messages from the worker appear in stdout during browser-runner tests, including in headless mode.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.