vitest-dev / vitest-dev/vitest

Browser mode throws "Failed to fetch dynamically imported module"

Open
#5,477 14 comments 13 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

I'm in the process of comparing all of the test runners on a very basic vue 3 composition API + TS app. So i setup testing lib and a basic test, it worked. Then I tried to add @vitest/browser and I updated vitest.config.ts to use playwright and chromium but vitest started errors like

ReferenceError: Vue is not defined

Reproduction

I haven't seen this error anywhere else but I reproduced it in StackBlitz, the setup is fairly similar to the one on my machine and gives the same result

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

Could it be a setup error on my part ? Or is it a bug ?

System Info
 System:
    OS: macOS 14.3
    CPU: (8) arm64 Apple M2
    Memory: 532.70 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.14.2 - ~/.nvm/versions/node/v18.14.2/bin/node
    npm: 9.5.0 - ~/.nvm/versions/node/v18.14.2/bin/npm
    pnpm: 8.15.3 - /opt/homebrew/bin/pnpm
    bun: 1.1.0 - ~/.bun/bin/bun
  Browsers:
    Chrome: 123.0.6312.87
    Safari: 17.3
  npmPackages:
    @vitejs/plugin-vue: ^4.6.2 => 4.6.2 
    @vitest/browser: ^1.4.0 => 1.4.0 
    @vitest/ui: ^1.4.0 => 1.4.0 
    vite: ^4.5.3 => 4.5.3 
    vitest: ^1.4.0 => 1.4.
Used Package Manager

npm

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 StackBlitz reproduction and inspect vitest.config.ts, focusing on @vitest/browser with Playwright and Chromium in the Vue 3 TypeScript app. Run the browser test to reproduce the dynamic-import failure and Vue is not defined error; done means the same setup runs without either error.

Written by the indexing model from the issue text.

Assessment

Tech stack
playwright, typescript, vite
Domain
frontend, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.