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

Redundant stderr log for browser mode test failure #4889

Closed
6 tasks done
hi-ogawa opened this issue Jan 7, 2024 · 0 comments · Fixed by #4891
Closed
6 tasks done

Redundant stderr log for browser mode test failure #4889

hi-ogawa opened this issue Jan 7, 2024 · 0 comments · Fixed by #4891
Labels
feat: browser Issues and PRs related to the browser runner

Comments

@hi-ogawa
Copy link
Contributor

hi-ogawa commented Jan 7, 2024

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

@sheremet-va sheremet-va added bug feat: browser Issues and PRs related to the browser runner and removed pending triage labels Jan 11, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jan 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: browser Issues and PRs related to the browser runner
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants