vitest-dev / vitest-dev/vitest

__vitest_browser_runner__.runTests is not a function when browser mode x customzied root

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

Nobody has claimed this yet.

pending triage
Dominant language
TypeScript
Stars
17.1k
Forks
2k
Avg merge
1d 22h
Merged PRs (30d)
94

Description

Describe the bug

when the root is specified to an outside dir x browser mode
https://github.com/Jinjiang/reproductions/tree/vitest-browser-20250408

(not sure whether it's same to #6674)

Reproduction

https://github.com/Jinjiang/reproductions/tree/vitest-browser-20250408

cd tool
pnpm install

# it works
pnpm test
# it works
pnpm test2
# it doesn't work
pnpm test3

error:

Vitest caught 1 unhandled error during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
TypeError: __vitest_browser_runner__.runTests is not a function
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
System Info
System:
    OS: macOS 15.5
    CPU: (8) arm64 Apple M1
    Memory: 98.09 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.14.0 - ~/.local/share/mise/installs/node/22/bin/node
    Yarn: 1.22.18 - ~/.yarn/bin/yarn
    npm: 10.9.2 - ~/.local/share/mise/installs/node/22/bin/npm
    pnpm: 10.7.1 - ~/Library/pnpm/pnpm
    bun: 1.1.36 - ~/.local/share/mise/installs/bun/latest/bin/bun
  Browsers:
    Safari: 18.5
  npmPackages:
    @vitest/browser: ^3.1.1 => 3.1.1 
    playwright: ^1.51.1 => 1.51.1 
    vitest: ^3.1.1 => 3.1.1
Used Package Manager

pnpm

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 linked reproduction at Jinjiang/reproductions, enter its tool directory, install dependencies, and compare pnpm test, pnpm test2, and pnpm test3. Trace how browser mode handles a root outside the project directory and identify why the failing case exposes a missing runTests function. Done means the custom-root browser-mode case runs without the reported TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
playwright, typescript
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.