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

vitest list broken in browser mode #7065

Open
6 tasks done
Tackoil opened this issue Dec 11, 2024 · 1 comment
Open
6 tasks done

vitest list broken in browser mode #7065

Tackoil opened this issue Dec 11, 2024 · 1 comment
Labels
feat: browser Issues and PRs related to the browser runner p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@Tackoil
Copy link

Tackoil commented Dec 11, 2024

Describe the bug

vitest list cannot get the test cases in browser mode. It'll print following informations.

There were unhandled errors during test collection
{
  name: 'TypeError',
  message: "Cannot read properties of undefined (reading 'logger')",
  stack: "TypeError: Cannot read properties of undefined (reading 'logger')\n" +
    '    at DefaultReporter.onCollected (file:///Users/<username>/Developer/list-cases-error/node_modules/.pnpm/vitest@2.1.8_@types+node@22.10.1_@vitest+browser@2.1.8_msw@2.6.8_@types+node@22.10.1_/node_modules/vitest/dist/chunks/index.DsZFoqi9.js:4037:46)\n' +
...

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-yc2pz6w7

The following procedures could also reproduce this issue.

  1. mkdir to create a new folder, and npm init.
  2. npx vitest init browser to init the test with browser mode.
  3. modify test command in package.json to run vitest list
  4. run npm run test

System Info

System:
    OS: macOS 15.1.1
    CPU: (8) arm64 Apple M2
    Memory: 3.93 GB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.15.1 - ~/Library/pnpm/node
    npm: 10.7.0 - ~/Library/pnpm/npm
    pnpm: 9.15.0 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 131.0.6778.109
    Chrome Canary: 133.0.6879.0
    Safari: 18.1.1
  npmPackages:
    @vitest/browser: ^2.1.8 => 2.1.8
    vitest: ^2.1.8 => 2.1.8

Used Package Manager

npm

Validations

@hi-ogawa
Copy link
Contributor

I can reproduce with in-repo example:

$ pnpm -C examples/lit test list

> @vitest/example-lit@ test /home/hiroshi/code/others/vitest/examples/lit
> vitest "list"


There were unhandled errors during test collection
{
  name: 'TypeError',
  message: "Cannot read properties of undefined (reading 'config')",
  stack: "TypeError: Cannot read properties of undefined (reading 'config')\n" +
    '    at DefaultReporter.shouldLog (file:///home/hiroshi/code/others/vitest/packages/vitest/dist/chunks/index.DLpiz9QT.js:3184:18)\n' +
    '    at DefaultReporter.onUserConsoleLog (file:///home/hiroshi/code/others/vitest/packages/vitest/dist/chunks/index.DLpiz9QT.js:3145:15)\n' +
    '    at file:///home/hiroshi/code/others/vitest/packages/vitest/dist/chunks/cli-api.CYSzx7ai.js:11803:58\n' +
    '    at Array.map (<anonymous>)\n' +
    '    at Vitest.report (file:///home/hiroshi/code/others/vitest/packages/vitest/dist/chunks/cli-api.CYSzx7ai.js:11803:38)\n' +
    '    at Proxy.sendLog (file:///home/hiroshi/code/others/vitest/packages/browser/dist/index.js:2150:22)\n' +
    '    at WebSocket.onMessage (file:///home/hiroshi/code/others/vitest/packages/browser/dist/index.js:2052:29)\n' +
    '    at WebSocket.emit (node:events:518:28)\n' +
    '    at Receiver.receiverOnMessage (/home/hiroshi/code/others/vitest/node_modules/.pnpm/ws@8.18.0/node_modules/ws/lib/websocket.js:1220:20)\n' +
    '    at Receiver.emit (node:events:518:28)',
  stacks: [
    {
      method: 'Receiver.receiverOnMessage',
      file: '/home/hiroshi/code/others/vitest/node_modules/.pnpm/ws@8.18.0/node_modules/ws/lib/websocket.js',
      line: 1220,
      column: 20
    }
  ],
  type: 'Unhandled Rejection'
}

@hi-ogawa hi-ogawa added feat: browser Issues and PRs related to the browser runner p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: browser Issues and PRs related to the browser runner p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

No branches or pull requests

2 participants