Skip to content

Redundant stderr log for browser mode test failure #4889

@hi-ogawa

Description

@hi-ogawa

Describe the bug

I wasn't sure if this is a feature, but it looks a little confusing at first sight at least.
Minimal reproduction with example log and comparison with non-browser pools is here https://github.com/hi-ogawa/repro-vitest-browser-error-log-redundant.

This can be also quickly reproduced on Vitest repo:

$ pnpm -C test/browser exec vitest run test/failing.test.ts

RUN  v1.1.3 /home/hiroshi/code/others/vitest/test/browser
      Browser runner started at http://localhost:5173

stderr | unknown test                     //// <--- redundant automatic stderr log
expected 1 to be 2 // Object.is equality  ////      because test failure gets reported below anyway
 ❯ test/failing.test.ts (1)
   × correctly fails and prints a diff

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL  test/failing.test.ts > correctly fails and prints a diff       
AssertionError: expected 1 to be 2 // Object.is equality           
...

This log is coming from console.error in BrowserTestRunner.onAfterRunTask:

async onAfterRunTask(task: Test) {
await super.onAfterRunTask?.(task)
task.result?.errors?.forEach((error) => {
console.error(error.message)
})

The code runs on browser, so this essentially allows error.message to show up on browser devtools, but for default reporter, spied console is also redirected to terminal and it looks redundant there.

I suspect this could be a unintended debug logging, but I would appreciate if someone can confirm that's really the case.

Reproduction

https://github.com/hi-ogawa/repro-vitest-browser-error-log-redundant

System Info

System:
    OS: Linux 6.6 Arch Linux
    CPU: (12) x64 AMD Ryzen 5 5625U with Radeon Graphics
    Memory: 2.68 GB / 14.98 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 18.19.0 - ~/.volta/tools/image/node/18.19.0/bin/node
    Yarn: 1.22.19 - ~/.volta/tools/image/yarn/1.22.19/bin/yarn
    npm: 10.2.3 - ~/.volta/tools/image/node/18.19.0/bin/npm
    pnpm: 8.12.0 - ~/.volta/tools/image/node/18.19.0/bin/pnpm
  Browsers:
    Chromium: 120.0.6099.199
  npmPackages:
    @vitest/browser: latest => 1.1.3 
    vite: latest => 5.0.11 
    vitest: latest => 1.1.3

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: browserIssues and PRs related to the browser runner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions