Vitest browser mode: `resolve.conditions` is missing `'browser'`
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- nuxt, typescript, vite
- Domain
- testing
Research direction
Start in src/config.ts and compare the configured resolve.conditions with Vite’s defaults. Reproduce the reported browser-mode failure using the linked StackBlitz example or the project’s relevant tests. Done means browser-specific package files resolve correctly and the existing test suite still passes.
Written by the indexing model from the issue text.
Description
Reproduction
https://stackblitz.com/edit/github-sbsck7pd
Describe the bug
In src/config.ts the resolve.conditions are set to ['web', 'import', 'module', 'default']. One of the Vite default options 'browser' is missing. This makes packages load files that should not be loaded in a browser environment.
In the reproduction the package @msw/interceptor tries to load files but run into errors.
Additional context
- Found by Claude
- I could have opened an MR directly, but because the Nuxt test utils are quite complex, I wasn't sure if the simple change would be correct and/or enough
Workaround
As a workaround you can add the following to the Vite/Vitest config:
resolve: {
conditions: ['browser'],
},
Vite deeply merges config options from plugins into the user configuration.
- Dominant language
- TypeScript
- Stars
- 440
- Forks
- 120
- Avg merge
- 5d 22h
- Merged PRs (30d)
- 22
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nuxt/test-utils
-
Nuxt v4.6.0 nightly: `@nuxt/test-utils/module` causes colocated tests to be registered as app files, causing import-protection errors during devPossibly taken @yamachi4416 claimed this 6 days ago. Openpending triage
Difficulty 3/5 1-2 days Newbie friendliness 68/100
nuxt/test-utils#1833 · 3 comments ·
Maintainers usually reply within 1 day
-
pending triage
Difficulty 3/5 1-2 days Newbie friendliness 55/100
nuxt/test-utils#1671 · 4 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
pending triage
Difficulty 4/5 3-5 days Newbie friendliness 52/100
nuxt/test-utils#1607 · 2 comments ·
Maintainers usually reply within 1 day
-
`@vitest-environment-options` is not workingPossibly taken @yamachi4416 claimed this 170 days ago. Openpending triage
Difficulty 3/5 1-2 days Newbie friendliness 45/100
nuxt/test-utils#1541 · 2 reactions ·
Maintainers usually reply within 1 day
-
Nuxt `multiApp` breaks nuxt/test-utilsPossibly taken @nicolaspayot claimed this 870 days ago. Openpending triage
Difficulty 4/5 3-5 days Newbie friendliness 48/100
nuxt/test-utils#1521 · 1 comment · 4 reactions ·
Maintainers usually reply within 1 day
Similar issues
-
Add: YRF Music NepalOpenstreams:add
Difficulty 1/5 Under an hour Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
walletbeat/walletbeat#1558 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
hawk-digital-environments/HAWKI#438 ·
Maintainers usually reply within 1 day
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
GiganticMinecraft/seichi-portal-frontend#1165 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day