Skip to content

vitest 4.0 fails with "TypeError: filename.replace is not a function" #14628

@jyasskin

Description

@jyasskin

Astro Info

> @example/[email protected] astro
> astro info

Astro                    v5.15.1
Vite                     v6.4.1
Node                     v20.19.1
System                   Linux (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

After cloning https://github.com/withastro/astro/tree/latest/examples/with-vitest and upgrading vitest to 4.0, running npm test results in the following error. This resembles cloudflare/workers-sdk#9036, but I believe Astro isn't yet compatible with vite 7.0, so the fix there won't work.

FAIL  test/basic.test.ts [ test/basic.test.ts ]
TypeError: filename.replace is not a function
  Plugin: vite:import-analysis
  File: /home/projects/yqnipnbnqy.github/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

What's the expected result?

The example project should pass its test under the new vitest version.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-ndmldv3d?file=package.json

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions