Environment
- Operating System:
Linux
- Node Version:
v23.5.0
- Nuxt Version:
4.2.1
- CLI Version:
3.30.0
- Nitro Version:
2.12.9
- Package Manager:
bun@1.3.2
- Builder:
-
- User Config:
compatibilityDate, devtools, modules
- Runtime Modules:
@nuxt/test-utils/module@3.20.1
- Build Modules:
-
Reproduction
https://github.com/tpfaffenbauer/ntu-bun-repro
Describe the bug
I've set up a new project this week with v3.20.1 and after following the installation instructions for @nuxt/test-utils I'm not able to run tests using bun run vitest due to the following error:
Error: Cannot bundle built-in module "bun:test" imported from "node_modules/@nuxt/test-utils/dist/shared/test-utils.CtoalVlS.mjs". Consider disabling environments.client.noExternal or remove the built-in dependency.
I noticed bun happily installs Vitest v4.0.0 without complaints even though the peer dependency is set to v3.2.0. npm refuses and installs v3.2.4 instead. When using bun, hard locking the Vitest version to v3.2.4 runs the test successfully. Is @nuxt/test-utils expected to work with Vitest 4 yet?
Additional context
No response
Logs
FAIL nuxt ../test/nuxt/someTest.test.ts [ test/nuxt/someTest.test.ts ]
Error: Cannot bundle built-in module "bun:test" imported from "node_modules/@nuxt/test-utils/dist/shared/test-utils.CtoalVlS.mjs". Consider disabling environments.client.noExternal or remove the built-in dependency.
Plugin: vite:import-analysis
File: /home/tom/ntu-repro/node_modules/@nuxt/test-utils/dist/shared/test-utils.CtoalVlS.mjs:117:31
115 |
116 | async function setupBun(hooks) {
117 | const bunTest = await import('bun:test');
| ^
118 | hooks.ctx.mockFn = bunTest.mock;
119 | bunTest.beforeAll(hooks.beforeAll);
❯ ResolveIdContext._formatLog ../node_modules/vite/dist/node/chunks/config.js:29618:43
❯ ResolveIdContext.error ../node_modules/vite/dist/node/chunks/config.js:29615:14
❯ ResolveIdContext.handler ../node_modules/vite/dist/node/chunks/config.js:33197:13
❯ EnvironmentPluginContainer.resolveId ../node_modules/vite/dist/node/chunks/config.js:29336:56
❯ TransformPluginContext.resolve ../node_modules/vite/dist/node/chunks/config.js:29548:13
❯ normalizeUrl ../node_modules/vite/dist/node/chunks/config.js:27730:22
❯ ../node_modules/vite/dist/node/chunks/config.js:27796:32
❯ TransformPluginContext.transform ../node_modules/vite/dist/node/chunks/config.js:27764:4
❯ EnvironmentPluginContainer.transform ../node_modules/vite/dist/node/chunks/config.js:29416:14
Environment
Linuxv23.5.04.2.13.30.02.12.9bun@1.3.2-compatibilityDate,devtools,modules@nuxt/test-utils/module@3.20.1-Reproduction
https://github.com/tpfaffenbauer/ntu-bun-repro
Describe the bug
I've set up a new project this week with
v3.20.1and after following the installation instructions for@nuxt/test-utilsI'm not able to run tests usingbun run vitestdue to the following error:I noticed bun happily installs Vitest
v4.0.0without complaints even though the peer dependency is set tov3.2.0. npm refuses and installsv3.2.4instead. When using bun, hard locking the Vitest version tov3.2.4runs the test successfully. Is@nuxt/test-utilsexpected to work with Vitest 4 yet?Additional context
No response
Logs