Skip to content

vi.mock not working in browser mode with test files outside of root #7595

@miguel-leon

Description

@miguel-leon

Describe the bug

I read it was implemented, but I can't get it to work. It works as expected when run in node though.

Is there a special configuration required that I haven't found in the docs?

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-pywprx8q?file=vite.config.ts

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @vitest/browser: latest => 3.0.7 
    @vitest/ui: latest => 3.0.7 
    playwright: latest => 1.50.1 
    vite: latest => 6.2.0 
    vitest: latest => 3.0.7 
    webdriverio: latest => 9.10.1

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: browserIssues and PRs related to the browser runnerp3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions