-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Vitest 4 broke Astro tests ("filename.replace is not a function") #8899
Copy link
Copy link
Labels
Description
Describe the bug
I initially reported this at withastro/astro#14628, but as with #8859, maybe it's more fixable over here. This is similar to cloudflare/workers-sdk#9036, but Astro hasn't yet updated to vite 7, so the fix there doesn't work yet. Running the demo Astro tests with vitest upgraded to 4.0.6 (that is, after the fix for #8859), I get:
FAIL test/basic.test.ts [ test/basic.test.ts ]
TypeError: filename.replace is not a function
Plugin: vite:import-analysis
File: /home/projects/github-ndmldv3d/test/basic.test.ts
❯ normalizePath node_modules/vite/dist/node/chunks/dep-D4NMHUTW.js:600:21
❯ getMatcherString$1 node_modules/vite/dist/node/chunks/dep-D4NMHUTW.js:605:16
❯ Object.test node_modules/vite/dist/node/chunks/dep-D4NMHUTW.js:624:33
❯ result node_modules/vite/dist/node/chunks/dep-D4NMHUTW.js:645:25
❯ eval node_modules/vite/dist/node/chunks/dep-D4NMHUTW.js:15732:30
❯ eval node_modules/vite/dist/node/chunks/dep-D4NMHUTW.js:15747:74
❯ shouldExternalize node_modules/vite/dist/node/chunks/dep-D4NMHUTW.js:15667:10
❯ eval node_modules/vite/dist/node/chunks/dep-D4NMHUTW.js:40668:19
❯ TransformPluginContext.transform node_modules/vite/dist/node/chunks/dep-D4NMHUTW.js:40614:17
Reproduction
https://stackblitz.com/edit/github-ndmldv3d?file=package.json (Run npm test) This is https://github.com/withastro/astro/tree/latest/examples/with-vitest with vitest updated to 4.0.6.
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: 20.19.1 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.8.2 - /usr/local/bin/npm
pnpm: 8.15.6 - /usr/local/bin/pnpm
npmPackages:
vitest: ^4.0.6 => 4.0.6Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable